function getHTTPObject() {
  var xmlhttp;
 
  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (!xmlhttp){
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    
}
  return xmlhttp;

  
}
var http = getHTTPObject(); // We create the HTTP Object

/*
	Funtion Name=requestInfo 
	Param = url >> Url to call : id = Passing div id for multiple use ~ as a seprator for eg. div1~div2 :
	redirectPage >> if you like to redirect to other page once the event success then 
	the response text = 1 and the redirectPage not left empty
*/

    function requestInfo(url,id,redirectPage) {      
		var temp=new Array();
		var temp=id.split("~"); // To display on multiple div 
		document.getElementById(temp[0]).innerHTML="Loading .... ";	
			http.open("GET", url, true);
			http.onreadystatechange = function() {
				if (http.readyState == 4) {
				  if(http.status==200) {
			  		var results=http.responseText;
					if(redirectPage=="" || results!="1") {
						
						var temp=id.split("~"); // To display on multiple div 
						//alert(temp.length);
						var r=results.split("~"); // To display multiple data into the div 
						//alert(temp.length);
						if(temp.length>1) {
							for(i=0;i<temp.length;i++) {	
								//alert(temp[i]);
								document.getElementById(temp[i]).innerHTML=r[i];
							}
						} else {
							document.getElementById(id).innerHTML = results;
						}	
					} else {
						//alert(results);
						window.location.href=redirectPage;			
					}
				  } 
  				}
			};
			http.send(null);
       }

	
	
function confirmLink(theLink)
{
   
    var is_confirmed = confirm('Are you sure to delete this record?\n\nThis will permanently delete the Record!');
    if (is_confirmed) {
        theLink.href += '';
    }

    return is_confirmed;
}


function selectall(formId) {
	var frmId=document.getElementById(formId);
	var reclen =  frmId.length;
	for(i=0;i<reclen;i++) {

		//if(frmId.elements[i].checked==true) {
			//frmId.elements[i].checked=false;	
		//} else {
			frmId.elements[i].checked=true;		
		//}
	}
	
}


function uncheckall(formId) {
	var frmId=document.getElementById(formId);
	var reclen =  frmId.length;
	for(i=0;i<reclen;i++) {

		//if(frmId.elements[i].checked==true) {
			//frmId.elements[i].checked=false;	
		//} else {
			frmId.elements[i].checked=false;		
		//}
	}
	
}

function confirm_del(theLink,formId)
{
   
    var is_confirmed = confirm('Are you sure to delete this record?\n\nThis will permanently delete the Record!');
    if (is_confirmed) {
		
		var frmId=document.getElementById(formId);
		var reclen =  frmId.length;
		var one=0;
		for(i=0;i<reclen;i++) {
			if(frmId.elements[i].checked==true) {
				one+=1;
			}
		}
		if(one>0) {	
	        theLink.href += '';
		} else {
			alert("No Record Selected. \nPlease select at least one record to delete ");
			return false;
		}
    }

    return is_confirmed;
}


function toggle(el,image,url) {
	var el=document.getElementById(el);
	var imgsrc=document.getElementById(image);
	if(el.style.display=="none")  {
		el.style.display="inline";
		imgsrc.src=url+"/administrator/images/menuMinus.gif";
	} 	else  {
		el.style.display="none";
		imgsrc.src=url+"/administrator/images/menuPlus.gif";
	}
}


function explode(inputstring, separators, includeEmpties) {
   inputstring = new String(inputstring);
   separators = new String(separators);

   if(separators == "undefined") { 
      separators = " :;";
   }

   fixedExplode = new Array(1);
   currentElement = "";
   count = 0;

   for(x=0; x < inputstring.length; x++) {
      char = inputstring.charAt(x);
      if(separators.indexOf(char) != -1) {
         if ( ( (includeEmpties <= 0) || (includeEmpties == false)) && (currentElement == "")) { }
         else {
            fixedExplode[count] = currentElement;
            count++;
            currentElement = ""; } }
      else { currentElement += char; }
   }

  if (( ! (includeEmpties <= 0) && (includeEmpties != false)) || (currentElement != "")) {
      fixedExplode[count] = currentElement; }
   return fixedExplode;
}


function getCheckedValue(radioObj) {
	if(!radioObj) return "false";
	var radioLength = radioObj.length;
	alert(radioLength + radioObj);
	if(radioLength == undefined)
		if(radioObj.checked)
		return radioObj.value;
		else
		return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


		

function validateSituAssm() {
	/*
	var chks = document.getElementsByName('assmQuesIDs[]');
	var questions = chks.length;
	counter=0
	for(i=0;i<document.frmAssmSituation.length - 2;i++) {
		if(document.frmAssmSituation.elements[i].checked==true)	{
			counter++;
		}  
	}
	if(counter<questions*2) {
		alert("Pleae Check ");				
		return false;
	} else {
		return true;
	}
	*/
	
}




function checkSignUp(){
	if(document.frmSubscriber.user_name.value=="") {
		alert("Type Username ");	
		document.frmSubscriber.user_name.focus();
		return false;
	} else if(document.frmSubscriber.password.value=="") {
		alert("Enter Password");
		document.frmSubscriber.password.focus();
		return false;
	} else if(document.frmSubscriber.repassword.value=="") {
		alert("Enter Re Password");
		document.frmSubscriber.repassword.focus();	
		return false;
	} else if(document.frmSubscriber.password.value!=document.frmSubscriber.repassword.value) {
			alert("Password Doesn't Match");
			return false;
	} else if(document.frmSubscriber.first_name.value=="") {
		alert("Enter First Name ");
		document.frmSubscriber.first_name.focus();		
		return false;
	} else if(document.frmSubscriber.last_name.value=="") {
		alert("Enter Last Name ");
		document.frmSubscriber.last_name.focus();
		return false;
	} else if(document.frmSubscriber.street.value=="") {
		alert("Enter Street Name");
		document.frmSubscriber.street.focus();	
		return false;
	} else if(document.frmSubscriber.city.value=="") {
		alert("Enter City Name");
		document.frmSubscriber.city.focus();		
		return false;
	} else if(document.frmSubscriber.country.value=="" || document.frmSubscriber.country.value=="0") {
		alert("Enter Country Name");
		document.frmSubscriber.country.select();			
		return false;
	} else if(document.frmSubscriber.gender.value=="") {
		alert("Select Gender Name");
		document.frmSubscriber.gender.select();				
		return false;
	} else if(document.frmSubscriber.email_address.value=="") {
		alert("Enter Email Address ");
		document.frmSubscriber.email_address.focus();					
		return false;
	} else if(document.frmSubscriber.email_address_confirm.value=="") {
		alert("Enter Confirm Email Address ");
		document.frmSubscriber.email_address_confirm.focus();					
		return false;
	} else if(document.frmSubscriber.secret_question.value=="") {
		alert("Select Secret Question");
		document.frmSubscriber.secret_question.focus();
		return false;
	} else if(document.frmSubscriber.secret_answer.value=="") {
		alert("Select Secret Answer");
		document.frmSubscriber.secret_answer.focus();	
		return false;
	} else if(document.frmSubscriber.security_code.value=="") {
		alert("Select Security Code");
		document.frmSubscriber.security_code.focus();		
		return false;
	}  else {
		return true;	
	}
}


