/*This function changes action of the form and submits it to fetch_contacts.php*/
var id	=	0;
var id2	=	0;
var index	=	0;
function fetchContacts()
{
	var contactString = "";
	var count		  =  0;
	
	for(var i = 0;i < document.getElementById("selContacts[]").options.length;i++)
	{
		if(document.getElementById("selContacts[]").options[i].selected)
		{
			if(count > 0)
			{
				contactString += ",";
			}
				contactString += document.getElementById("selContacts[]").options[i].text;
				count++;
		}
	}
	
	document.form1.txtTo.value = contactString;
}

/*This function will make all checkboxes on the form checked or unchecked*/

function checkAll(CheckBoxControl)
{
	if(CheckBoxControl.checked == true)   
	{
		var i = 0;
		var j = 0;
		
		for (i=0; i < document.forms[0].elements.length; i++) 
		{
			if(document.forms[0].elements[i].name == "chkbox" + j)
			{
				document.forms[0].elements[i].checked = true;
			}
			j++;
		}
	}
	
	else if(CheckBoxControl.checked == false)
	{
		var i = 0;
		var j = 0;
		
		for (i=0; i < document.forms[0].elements.length; i++) 
		{
			if(document.forms[0].elements[i].name == "chkbox" +j)
			{
				document.forms[0].elements[i].checked = false;
			}
			j++;
		}
	}
}

/*This function will make all checkboxes on the form checked or unchecked*/

function checkAllOneOne(CheckBoxControl)
{ 

	
	if(CheckBoxControl.checked == true)   
	{ 
		var i = 0;
		var j = 1;
		
		for (i=1; i < document.forms[0].elements.length; i++) 
		{	
			
			if(document.forms[0].elements[i].name == "chkbox" + j)
			{	
				document.forms[0].elements[i].checked = true;
				j++;
			}
		}
	}
	
	else if(CheckBoxControl.checked == false)
	{
		var i = 0;
		var j = 1;
		
		for (i=1; i < document.forms[0].elements.length; i++) 
		{
			if(document.forms[0].elements[i].name == "chkbox" +j)
			{
				document.forms[0].elements[i].checked = false;
				j++;
			}
		}
	}
}

/*This function will make all checkboxes on the form checked or unchecked*/

function checkAllOneOne1(CheckBoxControl)
{ 
	
	if(CheckBoxControl.checked == true)   
	{ 
		var i = 0;
		var j = 1;
		
		for (i=1; i < document.form1.elements.length; i++) 
		{	
			
			if(document.form1.elements[i].name == "chkbox" + j)
			{	
				document.form1.elements[i].checked = true;
				j++;
			}
		}
	}
	
	else if(CheckBoxControl.checked == false)
	{
		var i = 0;
		var j = 1;
		
		for (i=1; i < document.form1.elements.length; i++) 
		{
			if(document.form1.elements[i].name == "chkbox" +j)
			{
				document.form1.elements[i].checked = false;
				j++;
			}
		}
	}
}

/*This function will make all checkboxes on the form checked or unchecked*/






function checkAllOne(CheckBoxControl)
{
	if(CheckBoxControl.checked == true)   
	{
		var i = 0;
		var j = 1;
		for (i=1; i < document.forms[0].elements.length; i++) 
		{
//			alert (document.forms[0].elements[i].name + "==" + "chkbox" + j);
			if(document.forms[0].elements[i].name == "chkbox" + j)
			{
//				alert(document.forms[0].elements[i].name + "now checked");
				document.forms[0].elements[i].checked = true;
				j++;
			}
		}
	}
	
	else if(CheckBoxControl.checked == false)
	{
		var i = 0;
		var j = 1;
		
		for (i=1; i < document.forms[0].elements.length; i++) 
		{
//			alert (document.forms[0].elements[i].name + "==" + "chkbox" + j);
			if(document.forms[0].elements[i].name == "chkbox" +j)
			{
				document.forms[0].elements[i].checked = false;
				j++;
			}
		}
	}
}


//.......................................................................................
function getCountry(cont)
	{ 
	alert(cont);
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
 			{
 				alert ("Browser does not support HTTP Request");
				 return;
		 	}
		var url="get_countries_by_continent.php";
		url=url+"?cont="+cont;
		//url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChangedCountriesByContinents;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}

//.......................................................................................
function stateChangedCountriesByContinents()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//alert(xmlHttp.responseText);
		document.getElementById('response_countries').innerHTML=xmlHttp.responseText;
	} 

}

//.......................................................................................

function show_egift_popup(str,str1)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
 			{
 				alert ("Browser does not support HTTP Request");
				 return;
		 	}
		var url="get_state.php";
		if(screen.width<=800)
			{
				url=url+"?flg=show_egift&id="+str;
			}
		else
			{
				url=url+"?flg=show_egift&id="+str1;
			}
		//url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChangedForshow_egift_popup;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
function stateChangedForshow_egift_popup() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 			{ 
 				//alert(xmlHttp.responseText);
				document.getElementById('egift_pop').innerHTML=xmlHttp.responseText;
				showDiv('egift_pop');
			} 
	}
//.......................................................................................
function show_edit_egift_popup(str,str1)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
 			{
 				alert ("Browser does not support HTTP Request");
				 return;
		 	}
		var url="get_state.php";
		if(screen.width<=800)
			{
				url=url+"?flg=show_edit_egift&id="+str;
			}
		else
			{
				url=url+"?flg=show_edit_egift&id="+str1;
			}
		//url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=stateChangedForshow_edit_egift_popup;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
function stateChangedForshow_edit_egift_popup() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 			{ 
 				//alert(xmlHttp.responseText);
				document.getElementById('egift_pop').innerHTML=xmlHttp.responseText;
				showDiv('egift_pop');
			} 
	}
//.......................................................................................
function showArticleDetail()
	{
		document.getElementById('article_detail').style.display='block';
	}

//.......................................................................................
function RotateImages(arrayImages)
	{
		
		var mytool_array=arrayImages.split(",");
		if(mytool_array.length-1==index)
			{
				index=0;
			}
		else
			{
				index++;
			}
		
	document.getElementById("showimages").src = "upload/Portfolio/"+mytool_array[index];

	}
//.......................................................................................
function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try
 			{
 				// Firefox, Opera 8.0+, Safari
 				xmlHttp=new XMLHttpRequest();
 			}
		catch (e)
 			{
 				//Internet Explorer
 				try
  					{
 			 			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  					}
 				catch (e)
  					{
 			  			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  					}
	 		}
		return xmlHttp;
	}
	

