function page(Url,DivId)

{ 

 var AJAX;

 try

 {	 

  document.getElementById(DivId).innerHTML="<img src='images/loader.gif'>";		 

  AJAX = new XMLHttpRequest();  

 }

 catch(e)

 {   

  try

  {     

   AJAX = new ActiveXObject("Msxml2.XMLHTTP");     

  }

  catch(e)

  {     

   try

   { 

    AJAX = new ActiveXObject("Microsoft.XMLHTTP");       

   }

   catch(e)

   {       

    alert("Your browser does not support AJAX.");       

    return false;       

   }     

  }   

 }

 AJAX.onreadystatechange = function()

 {

  if(AJAX.readyState == 4)

  {

   if(AJAX.status == 200)

   {

    document.getElementById(DivId).innerHTML = AJAX.responseText;   

   }

   else

   {

    alert("Error: "+ AJAX.statusText +" "+ AJAX.status);

	document.getElementById(DivId).innerHTML='';

   }

  }   

 }

 AJAX.open("get", Url, true);

 AJAX.send(null);

}



function jump(anc) {

location.href=anc;

}



var myText='';



function formValidator(arr){

	for(i=0;i<arr.length;i++){

		temp=arr[i].split('=');	

		field=temp[0];

		val=temp[1];

		if(val=='blank'){

			blankValidator(field);

		}
		
		if(val=='username'){

			userNameValidator(field);

		}		

		if(val=='email'){

			emailValidator(field);

		}	

		if(val=='password'){

			passwordValidator(field);

		}	

		if(val=='passwordconfirmation'){

			passwordConfirmationValidator(field);

		}		

	}

if(myText!=''){	

	alert('Invalid Details '+myText.toUpperCase());

	myText='';

	return false;

}else{
	
	if(document.myForm.button){
		disableMe(document.myForm.button);
	}	

	return true;
	
}

}



function blankValidator(field){

var obj='document.myForm.'+field;

var data=eval(obj+'.value');



 if ( eval(obj+'.selectedIndex')>=0 ){

   if (eval(obj+'.selectedIndex')==0) {

     myText=myText+field+', ';

   }

 }else{

   var obj='document.myForm.'+field;

   var data=eval(obj+'.value');

   if(data==''){

     myText=myText+field+', '; 

   }

  }

}

function userNameValidator(field){

var obj='document.myForm.'+field;

var data=eval(obj+'.value');



   if(data==''){
     myText=myText+field+' : Blank, '; 
  }else if(data.indexOf(".")!=-1){
	 myText=myText+field+' : Invalid Character "." , ';  
  }else if(data.indexOf(" ")!=-1){
	 myText=myText+field+' : Space Not Allowed , '; 
  }else if(data.indexOf("@")!=-1){
	 myText=myText+field+' : Invalid Character "@" , ';
  }else if(data.indexOf("at")!=-1){
	 myText=myText+field+' : Invalid Character "at" , ';
  }else if(data.indexOf("dot")!=-1){
	 myText=myText+field+' : Invalid Character "dot" , ';
  }
}

function passwordValidator(field){

var obj='document.myForm.'+field;

var data=eval(obj+'.value');

	if(data.length<6){

		myText=myText+field+', ';

	}

}



function passwordConfirmationValidator(field){

var obj='document.myForm.'+field;

var data=eval(obj+'.value');

	if(data!=document.myForm.password.value){

		myText=myText+field+', ';

	}

}



function emailValidator(field){

var obj='document.myForm.'+field;	

var data=eval(obj+'.value');

	if(data.indexOf('@')=='-1' || data.indexOf('.')=='-1'){

		myText=myText+field+', ';

	}

}



function checkavailable(){

	if(document.getElementById('useravailability-check').innerHTML.trim()=='0'){

	document.myForm.usernametaken.value='';

	}else{

	document.myForm.usernametaken.value='1';

	}

}

function checkemailavailable(){
//alert(document.getElementById('emailavailability-check').innerHTML.trim());
	if(document.getElementById('emailavailability-check').innerHTML.trim()=='0'){

	document.myForm.emailtaken.value='';

	}else{

	document.myForm.emailtaken.value='1';

	}

}



String.prototype.trim = function () {

    return this.replace(/^\s*/, "").replace(/\s*$/, "");

}



function delconfirm(url){

var sure=confirm('Are your sure to delete !');	

	if(sure){

	window.location=url;	

	}

}



function hideDiv(div){

	document.getElementById(div).style.display='none';

}

function showDiv(div){

	document.getElementById(div).style.display='block';

}



function get_radio_value(obj)

{

obj=eval("document.myForm."+obj);

for (var i=0; i < obj.length; i++)

   {

   if (obj[i].checked)

      {

      var rad_val = obj[i].value;

	  //alert(rad_val);

      }

   }

   return rad_val;

}

function printapp(app){
window.open('print.php?image='+app);
}

