var contentPasteAt = '';
var group_country = '';
var state = 'none';
var imgsrc = "";
var affactClass = "";
var hza = '';
var cursorfldname = '';
var temp_item_price = '';
var temp_index = '';
var profile_form_whataction = '';
var profile_form_profile_name = '';
var profile_form_id = '';
var profile_form_hide_id = '';
var send_mail_to_imported_users = '';
//var html_progressbar = "<div  id='view_membership'>";
function open_chat()
{
	window.open("./chat/flashchat.php",'welcome','width=725,height=525,menubar=no,status=yes, location=middle,toolbar=no,scrollbars=yes');
	
}
function open_judge_profile(profile_id)
{
	window.open("view_profile.php?profile_id=" + profile_id,'welcome','width=800,height=800,menubar=no,status=yes, location=middle,toolbar=no,scrollbars=yes');
	
}
function open_judge_profile_links(profile_id)
{
	window.open("view_partner_profile.php?profile_id=" + profile_id,'welcome','width=800,height=600,menubar=no,status=yes, location=middle,toolbar=no,scrollbars=yes');
}

var whitespace =" \t\n\r ";
function isWhitespace(str)
{    var i;
	 var flag
		 if (isEmpty(str)) return true;	
	    for (i = 0; i < str.length; i++)
 	   {   
 	       // Check that current character isn't whitespace.
 	       var c = str.charAt(i);

		   if (whitespace.indexOf(c) == -1)
		   		return false
 	   }	
 	   // All characters are whitespace.
		    return true;
						
}
function isEmpty(str)
{  
	return ((str == null) || (str.length == 0))
}
function validateEmail(mail)
{
	if(mail.indexOf("@")==-1 || mail.indexOf("@")==0 || (mail.indexOf("@")==(mail.length-1)))
		return false;
	if(mail.indexOf(".")==-1|| (mail.indexOf(".")==(mail.length-1))|| (mail.indexOf(".")-mail.indexOf("@")==1)|| (mail.indexOf(".")-mail.indexOf("@")==-1))
		return false;

	for(var i=0;i<mail.length;i++)
		if(mail.charAt(i)==" ")
			return false;

	return true;
}

function getAjaxCountry(id)
{
	contentPasteAt = "country_position";
	//alert(contentPasteAt);
	var url = "ajax_get_country_name.php?id=" + id;		
	loadXMLDocGroupForm(url);
}
function loadXMLDocGroupForm(url)
{
	// branch for native XMLHttpRequest object
	//alert(1);
	if (window.XMLHttpRequest)
	{
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChangeGroupForm;
		req.open("GET", url, true);
		req.send(null);
		// branch for IE/Windows ActiveX version
	}
	else if (window.ActiveXObject)
	{
		req = new ActiveXObject("Microsoft.XMLHTTP"); 
		if (req)
		{
			req.onreadystatechange = processReqChangeGroupForm;
			req.open("GET", url, true);
			req.send();
		}
	}
}

function processReqChangeGroupForm()
{
	// only if req shows "complete"
	if (req.readyState == 4)
	{
		
		// only if "OK"
		if (req.status == 200)
		{
			response = req.responseXML.documentElement;
			var urlpath='';
			//alert(response.getElementsByTagName('testingnode')[0].childNodes[x].data); inside for loop

			for(var x = 0; response.getElementsByTagName('urlpath')[0].childNodes[x]; x++ )
				 urlpath = urlpath.concat(response.getElementsByTagName('urlpath')[0].childNodes[x].data);			
			document.getElementById(contentPasteAt).innerHTML = urlpath;
			if(group_country == "")
			{
				
			}
			else
			{
				getGroupForThisCountry(0,'group_selection_id');
				group_country = "";
			}
			
		}
		else
		{
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

function delUserInMemberPage(id,act,sub_id)
{
	if(!confirm("Do you really want to delete this club."))
	{
		alert("Deletion Cancel");
	}
	else
	{
		
		var url = "membership_delete.php?id=" + id + "&act=" + act+ "&sub_id=" + sub_id;
		sendQuery(url,'POST','','view_membership');
		
		
	}
}

function delUserMainPhotoPage(id,act,sub_id)
{
	if(!confirm("Do you really want to delete this user."))
	{
		alert("Deletion Cancel");
	}
	else
	{
		//contentPasteAt = "view_membership";
		//document.getElementById(contentPasteAt).innerHTML = html_progressbar;
		//var sub_id,url_link; 
		//sub_id = document.register5.sub_id.value;
		//url_link = "?sub_id="+sub_id+"&club_name="+club_name+"&status_id="+status_id;
		var url = "membership_delete.php?id=" + id + "&act=" + act+ "&sub_id=" + sub_id;
		sendQuery(url,'POST','','view_membership');
		//var url = "membership_delete.php?id=" + id + "&act=" + act+ "&sub_id=" + sub_id;
		//loadXMLDocGroupForm(url);
	}
}

function explodeArray(item,delimiter) {
tempArray=new Array(1);
var Count=0;
var tempString=new String(item);
while (tempString.indexOf(delimiter)>0) {
tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
Count=Count+1
}
tempArray[Count]=tempString;
return tempArray;
}

function openNewWnd(fileName)
{
 	 window.open(fileName,"Details",'width=800,height=600,menubar=no,status=yes, location=middle,toolbar=no,scrollbars=yes');
}


function itinaryValidate()
{
	with(document.itinary_form)
	{
		if(event_club_name.value == "")
		{
			alert("Please Enter Club Name");
			event_club_name.focus();
			return false;
		}
		
		if(fromDay.options.selectedIndex=="0")
		{
			alert("Please enter from day");
			fromDay.focus();
			return false;
		}
		if(fromMonth.options.selectedIndex=="0")
		{
			alert("Please enter from month");
			fromMonth.focus();
			return false;
		}
		if(fromYear.options.selectedIndex=="0")
		{
			alert("Please enter from year");
			fromYear.focus();
			return false;
		}


		if(event_description.value == "")
		{
			alert("Please Enter Description");
			event_description.focus();
			return false;
		}
	}
}
function checkBlank(aTextField) {
	act_val = stringTrim(aTextField.value);
	if ((act_val.length==0) ||
   (act_val==null)) {
      return true;
   }
   else { return false; }
}
function stringTrim(strToTrim) {
	return(strToTrim.replace(/^\s+|\s+$/g, ''));
}


function delItinerary(uid,ey,em,ed,del_id)
{
	if(confirm("Are you sure want to delete this Itinerary."))
	{
		location.href = "view_itinerary.php?uid=" + uid + "&ey=" + ey + "&em=" + em + "&ed=" + ed + "&del_id=" + del_id;
	}
}

function getGroupForThisCountry(id,tag_id)
{
	contentPasteAt = tag_id;
	//alert(contentPasteAt);
	var url = "ajax_get_group_for_country.php?id=" + id;
	//alert(url);
	loadXMLDocGroupForm(url);
}
function get_country_without_all_option(tag_id,true_id)
{
	contentPasteAt = tag_id;
	if(true_id == 0)
	{
		group_country = "yes";
	}
	//alert(contentPasteAt);
	var url = "ajax_get_country_without_all_option.php?true_id=" + true_id;		
	loadXMLDocGroupForm(url);
}

function showMsgBoxForProfile(div_id,hide_id)
{
	//alert(div_id + name_portion + hide_id);
	document.getElementById(div_id).style.display='block';
	
	document.message_form.profile_id.value = hide_id;
	
		if(document.getElementById('s'))
	{
		document.getElementById('s').innerHTML = "";
	}
	showProfileName(hide_id,'pro_name');

}
function showProfileName(id,tag_id)
{
	contentPasteAt = tag_id;
	//alert(contentPasteAt);
	var url = "ajax_show_profile_name.php?id=" + id;		
	loadXMLDocGroupForm(url);
}
function showAdvertiserProfileName(id,tag_id)
{
	contentPasteAt = tag_id;
	//alert(contentPasteAt);
	var url = "ajax_show_profile_name.php?advertiser_id=" + id;		
	loadXMLDocGroupForm(url);
}
function showMsgBoxForQuickSearch(div_id,hide_id,search_id,val)
{
	//alert(div_id + name_portion + hide_id);
	document.getElementById(div_id).style.display='block';
	
	document.message_form_quick_search.profile_id.value = hide_id;
	document.message_form_quick_search.sname_text.value = search_id;
	/*if(document.getElementById('quick_search_form_id_a'))
	{
		document.getElementById('quick_search_form_id_a').style.display='none';
	}
	if(document.getElementById('quick_search_form_id_b'))
	{
		document.getElementById('quick_search_form_id_b').style.display='none';
	}
	if(document.getElementById('quick_search_form_id_c'))
	{
		document.getElementById('quick_search_form_id_c').style.display='none';
	}*/
	if(document.getElementById('qs'))
	{
		document.getElementById('qs').innerHTML = "";
	}
	if(val == 1)
	{
		showAdvertiserProfileName(hide_id,'pro_name_quick_search');
	}
	else
	{	
		showProfileName(hide_id,'pro_name_quick_search');
	}

}
function showAllQuickSearchDiv()
{
	document.getElementById('login_popup_quick_search').style.display='none';
	if(document.getElementById('quick_search_form_id_a'))
	{
		document.getElementById('quick_search_form_id_a').style.display='block';
	}
	if(document.getElementById('quick_search_form_id_b'))
	{
		document.getElementById('quick_search_form_id_b').style.display='block';
	}
	if(document.getElementById('quick_search_form_id_c'))
	{
		document.getElementById('quick_search_form_id_c').style.display='block';
	}
}
function messageValidate()
{
	with(document.message_form)
	{
	
			if(checkBlank(document.getElementById('your_name')))
			{
				alert("Please enter Your Name");
				document.getElementById('your_name').focus();
				return false;		
			}
			if(checkBlank(document.getElementById('your_email')))
			{
				alert("Please enter Your Email");
				document.getElementById('your_email').focus();
				return false;		
			}
			if(!validateEmail(document.getElementById('your_email').value))
			{
				alert("Invalid Email");
				document.getElementById('your_email').focus();
				return false;			
			}
			if(checkBlank(document.getElementById('subject')))
			{
				alert("Please enter Subject");
				document.getElementById('subject').focus();
				return false;		
			}		
			if(checkBlank(document.getElementById('message')))
			{
				alert("Please enter Message");
				document.getElementById('message').focus();
				return false;		
			}		
	}
}
function thisPageMmessageValidate()
{
	
			if(checkBlank(document.getElementById('your_name1')))
			{
				alert("Please enter Your Name");
				document.getElementById('your_name1').focus();
				return false;		
			}
			if(checkBlank(document.getElementById('your_email1')))
			{
				alert("Please enter Your Email");
				document.getElementById('your_email1').focus();
				return false;		
			}
			if(!validateEmail(document.getElementById('your_email1').value))
			{
				alert("Invalid Email");
				document.getElementById('your_email1').focus();
				return false;			
			}
			if(checkBlank(document.getElementById('subject1')))
			{
				alert("Please enter Subject");
				document.getElementById('subject1').focus();
				return false;		
			}		
			if(checkBlank(document.getElementById('message1')))
			{
				alert("Please enter Message");
				document.getElementById('message1').focus();
				return false;		
			}		
	
}

function messageValidateQuickSearch()
{
	
	with(document.message_form_quick_search)
	{
	

			if(checkBlank(document.getElementById('qs_your_name')))
			{
				alert("Please enter Your Name");
				document.getElementById('qs_your_name').focus();
				return false;		
			}
			if(checkBlank(document.getElementById('qs_your_email')))
			{
				alert("Please enter Your Email");
				document.getElementById('qs_your_email').focus();
				return false;		
			}
			if(!validateEmail(document.getElementById('qs_your_email').value))
			{
				alert("Invalid Email");
				document.getElementById('qs_your_email').focus();
				return false;			
			}
			if(checkBlank(document.getElementById('qs_subject')))
			{
				alert("Please enter Subject");
				document.getElementById('qs_subject').focus();
				return false;		
			}		
			if(checkBlank(document.getElementById('qs_message')))
			{
				alert("Please enter Message");
				document.getElementById('qs_message').focus();
				return false;		
			}		
	}
}