var xmlHttp

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;
}

//////////////////////////////////////////////////////////////////////
///// maverix: get picture and show /////
function showPic(cat,ts)
{ 
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 } 
	if(cat=='directors') {
		url='showDirector.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()
		xmlHttp.onreadystatechange=showPicText
	}
	if(cat=='commercials') {
		url='showCommercial.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()
		xmlHttp.onreadystatechange=showPicText
	}
	if(cat=='illustrators') {
		url='showIllustrator.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()	
		xmlHttp.onreadystatechange=showPicText
	}
	if(cat=='fineartists') {
		url='showFineartist.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()	
		xmlHttp.onreadystatechange=showPicText
	}
	if(cat=='archives') {
		url='showArchive.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()
		xmlHttp.onreadystatechange=showPicText
	}
	if(cat=='publisher') {
		url='showPublisher.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()
		xmlHttp.onreadystatechange=showPicText_publisher
	}

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function showPicText() 
{ 
	if(xmlHttp.readyState !=4 ){
		 document.getElementById("box_b").innerHTML = "<div id='loadingText'><strong> </strong></div>";		
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		var data = xmlHttp.responseText;
		 document.getElementById("box_b").innerHTML = data;
	 } 
}
function showPicText_publisher() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		var data = xmlHttp.responseText.split('&__&');
		document.getElementById("box_k").innerHTML = data[0];
		document.getElementById("publisher_images").innerHTML = data[1];
		document.getElementById("publisher_title").innerHTML = data[2];
	 } 
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
///// maverix: get picture and show /////
function showInnerPic(cat,ts)
{ 
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 } 
	if(cat=='illustrator') {
		url='showInnerIllustrator.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()
		xmlHttp.onreadystatechange=showInnerPicText
	}
	if(cat=='fineartist') {
		url='showInnerFineartist.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()
		xmlHttp.onreadystatechange=showInnerPicText
	}
	if(cat=='publishing') {
		url='showInnerPublishing.php';
		var url = url+"?cat="+cat+"&ts="+ts+"&sid="+Math.random()
		xmlHttp.onreadystatechange=showInnerPicText_publishing
	}

	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function showInnerPicText() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		var data = xmlHttp.responseText;
		var datas = data.split('&__&');
		document.getElementById('vido_player').innerHTML = datas[0];
		document.getElementById('righttext').innerHTML = datas[1];
	 } 
}
function showInnerPicText_publishing() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		var data = xmlHttp.responseText;
		var datas = data.split('&__&');
		document.getElementById('rightcontent_p1').innerHTML = datas[0];
		document.getElementById('rightcontent_p2').innerHTML = datas[1];
		document.getElementById('righttext').innerHTML = datas[2];
	 } 
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
///// maverix: get picture and show /////
function getCommercial(id)
{ 
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 } 
	
	var url = "getContents.php?function=commercial&id="+id+"&sid="+Math.random()
	xmlHttp.onreadystatechange=showCommercialText
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function showCommercialText() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		var data = xmlHttp.responseText;
		var datas = data.split("___");
		
		document.getElementById("commercial_title").innerHTML = datas[0];
		document.getElementById("commercial_client").innerHTML = datas[1];
		document.getElementById("commercial_agency").innerHTML = datas[2];
		document.getElementById("commercial_description").innerHTML = datas[3];
	} 
}
//////////////////////////////////////////////////////////////////////
function open_video(video_file, video_image, w, h){
	var s1 = new SWFObject("mediaplayer.swf","mediaplayer",w,h,"7");
	s1.addParam("allowfullscreen","true");
	s1.addVariable("width",w);
	s1.addVariable("height",h);
	s1.addVariable("file",video_file);
	s1.addVariable("image",video_image);
	s1.addVariable("autostart","true");
	s1.write("vido_player");
}
//////////////////////////////////////////////////////////////////////

function go(str)
{
	window.location = "/"+str+".htm";
}
function go_com(str)
{
	window.location = "/commercial_"+str+".htm";
}
function go_ind(str)
{
	window.location = "/independent_"+str+".htm?where=main";
}
function go_director(id)
{
	window.location = "/commercial_director.htm?bio=y&id="+id;
}
function go_illustrator(id)
{
	window.location = "/commercial_illustrator.htm?bio=y&id="+id;
}
function go_publisher(id)
{
	window.location = "/independent_publishing.htm?bio=y&id="+id;
}
function go_commercial(myself,id,cid)
{
	window.location = myself+"?id="+id+"&cid="+cid;
}
function go_archive(director_id,cid)
{
	window.location = "/commercial_archive.htm?id="+director_id+"&cid="+cid;
}
function go_illustration(myself,id,cid)
{
	window.location = myself+"?id="+id+"&cid="+cid;
}
function go_fineartist(id)
{
	window.location = "/independent_fineartist.htm?id="+id;
}
function changePic(obj){
	alert(obj.src);
}
//////////////////////////////////////////////////////////////////////
/////////// Jadsters functions ///////////////////////////////////////
//////////////////////////////////////////////////////////////////////
function main(str)
{
	if(str == 'watchmovie'){
		location.href = "m_"+str+".htm";
	}else{
		location.href = "m_"+str+".htm#middles";
	}
}

function account(str)
{
	if(str == 'favorite'){
		location.href = "a_"+str+".htm";
	}else{
		location.href = "a_"+str+".htm#middles";
	}
}

function ShippingType(a)
{
	var b = $('shipcost');
	var c = $('shipping_cost');
		
	if(a == 1){
		b.style.display = 'block';
		c.disabled = '';
		c.value = '';
	}
	if(a == 2){
		b.style.display = 'none';	
		c.disabled = 'disabled';
		c.value = '0';
	}
}

function del_init()
{
	document.frmTest.email.value = '';
	document.frmTest.passwd.value = '';
}

function delete_item(url,id,page)
{
	var r=confirm("Do you want to delete?");

	if(r==true){
		document.location.href = "a_"+url+".htm?type=del&id="+id+"&page="+page+"#middles";
	}
}


function repost(tbl,ts)
{ 
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 } 

	var url = "repost.php"
		url = url+"?ts="+ts
		url = url+"&tbl="+tbl
		url = url+"&sid="+Math.random()

	xmlHttp.onreadystatechange=repostText
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function repostText() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		var data = xmlHttp.responseText;
		var datas = data.split('&__&');
		//alert(data);
		var ts = datas[0];
		document.getElementById("r"+ts).innerHTML = datas[1];
	 } 
}

function frmcheck()
{
	var title = document.uform.title;

	if(title.value == null || title.value == ''){
		return false;
	}else{
		document.uform.submit();
	}
}
