// JavaScript Document
function ajaxview( myid, myurl){
	//initial
	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;
	}
	//create XmlHttp object
	xmlHttp= GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return false;
	} 
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){  		
			
			document.getElementById(myid).innerHTML = xmlHttp.responseText;
			
			return true;
		}else{
			document.getElementById(myid).innerHTML = '<img src="/images/loading.gif" alt="loading" /> loading..';
		}
	}

	xmlHttp.open("GET",myurl,true);
	xmlHttp.send(null);
	
}
function ajaxview1( myid, myurl){
	//initial
	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;
	}
	//create XmlHttp object
	xmlHttp= GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return false;
	} 
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){  		
			document.getElementById(myid).innerHTML = stripslashes(xmlHttp.responseText);

			return true;
		}else{
			document.getElementById(myid).innerHTML = '<img src="/images/loading.gif" alt="loading" /> loading..';
		}
	}
	xmlHttp.open("GET",myurl,true);
	xmlHttp.send(null);
	
}
//-------------------------------------------------------------------------------------------
//show correct character.
function addslashes(str){
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');
	return str;
}
//-------------------------------------------------------------------------------------------
function stripslashes(str){
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}

function ajaxview_named(name, myid, myurl, async){
	if(async === undefined){
		async	= true
	}	
	
	//initial
	function GetXmlHttpObject(name){
		xmlHttp[name]=null;
		
		try{
			// Firefox, Opera 8.0+, Safari
			xmlHttp[name]=new XMLHttpRequest();
		}
		catch (e){
			// Internet Explorer
			try{
				xmlHttp[name]=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e){
				xmlHttp[name]=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp[name];
	}
	//create XmlHttp object
	var xmlHttp = new Array();
	xmlHttp[name]= GetXmlHttpObject(name);
	if (xmlHttp[name]==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	xmlHttp[name].onreadystatechange=function(){
		document.getElementById(myid).innerHTML="";
		if(xmlHttp[name].readyState==4 || (xmlHttp[name].status==200 && !async)){  		
			try{
				document.getElementById(myid).innerHTML = stripslashes(xmlHttp[name].responseText);
			}
			catch(e){}
			return true;
			
		}else{
			
			document.getElementById(myid).innerHTML = '<div width="100%" style="text-align:center;" height="100%; margin: auto;"><img src="'+domain_folder+'images/loading.gif" border="0" align="middle"/></div>';
		}
	}
	
	xmlHttp[name].open("GET",myurl, async);
	xmlHttp[name].send(null);

}
function ajaxdocument_title(name, myurl, async){
	if(async === undefined){
		async	= true
	}	

	//initial
	function GetXmlHttpObject(name){
		xmlHttp[name]=null;
		
		try{
			// Firefox, Opera 8.0+, Safari
			xmlHttp[name]=new XMLHttpRequest();
		}
		catch (e){
			// Internet Explorer
			try{
				xmlHttp[name]=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e){
				xmlHttp[name]=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp[name];
	}
	//create XmlHttp object
	var xmlHttp = new Array();
	xmlHttp[name]= GetXmlHttpObject(name);
	if (xmlHttp[name]==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	xmlHttp[name].onreadystatechange=function(){
		
		if(xmlHttp[name].readyState==4 || (xmlHttp[name].status==200 && !async)){  		
			try{

				document.title= stripslashes(xmlHttp[name].responseText);
			}
			catch(e){
				window.title= stripslashes(xmlHttp[name].responseText);	
			}
			return true;
			
		}else{
			

		}
	}
	
	xmlHttp[name].open("GET",myurl, async);
	xmlHttp[name].send(null);

}

function ajaxview_lookalikes( myid, myurl){
	//initial
	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;
	}
	//create XmlHttp object
	xmlHttp= GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
		return false;
	} 
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){  		
			
			document.getElementById(myid).innerHTML = xmlHttp.responseText;
			
				$("a[href$=.jpg], a[href$=.JPG],a[href$=.png].a[href$=.PNG],a[href$=.gif],a[href$=.GIF],a[href$=.jpeg],a[href$=.JPEG],a[rel$=lightbox]").fancybox({
					'transitionIn'	:	'elastic',
					'transitionOut'	:	'elastic',
					'speedIn'		:	600, 
					'speedOut'		:	200, 
					'overlayShow'	:	true,
					'type' : 'image'
				});
			$('.auto-submit-star').rating({
				callback: function(value, linkname){
					ajaxview_lookalikes('lookalikes' ,'/modules/home/lookalikes_vote.php?lookalikes_id='+document.getElementById('lookalikes_id').value+'&rating='+value);
					
			
				}
				});
			return true;
		}else{
			document.getElementById(myid).innerHTML = '<img src="/images/loading.gif" alt="loading" /> loading..';
		}
	}

	xmlHttp.open("GET",myurl,true);
	xmlHttp.send(null);
	
}
