var siteurl="http://www1.transtv.co.id/";
//var siteurl="http://www13.transtv.co.id/";

function setOpacity(domId, val) {
	obj = document.getElementById(domId);
	obj.style.MozOpacity = val;
	obj.style.opacity = val/10;
	obj.style.filter = 'alpha(opacity=' + val*10 + ')';
};

function fade(domId,str1){
	obj = document.getElementById(domId); //Get the Element
	if(obj.style.display == "none") return false; //Return false if the element is already hidden
	var alpha = 10; //Set the initial value of alpha to 10 (Opaque)
	function f(){ //Internal function
		alpha--; //Decrememnt the alpha value
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
		if(alpha > -1){ //If alpha is still bigger than -1 then..
			setTimeout(f, 100); //..then call the function again after 100 milliseconds
		}else{ //otherwise..
			obj.style.display = 'none'; //..otherwise now that we cant see the element anyways, hide it
		}
	}
	setTimeout(f, 100); //This is where we call the f() function for the first time



	document.getElementById(domId+"_t").innerHTML='<a class="'+str1+'colaps_t" href="javascript:appear(\''+domId+'\',\''+str1+'\');"></a>';


};

function appear(domId){
	obj = document.getElementById(domId); //Get the element
	if(obj.style.display != "none") return false; //Return if it is already being displayed
	obj.style.display = ''; //Un-hide the object before its animation
	var alpha = 0; //Set the initial value of alpha to 0 (invisible)
	function a(){ //Internal function
		alpha++; //Increment alpha
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
		if(alpha < 11)setTimeout(a, 100);
		/*Till alpha is 10, keep calling the
		a() function after 100 milliseconds */
	}
	setTimeout(a, 100); //This is where we call the a() function for the first time

	document.getElementById(domId+"_t").innerHTML='<a class="colaps" href="javascript:fade(\''+domId+'\');"></a>';
};


function fade2(domId,str1){
	obj = document.getElementById(domId); //Get the Element
	if(obj.style.display == "none") return false; //Return false if the element is already hidden
	var alpha = 10; //Set the initial value of alpha to 10 (Opaque)
	function f(){ //Internal function
		alpha--; //Decrememnt the alpha value
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
		if(alpha > -1){ //If alpha is still bigger than -1 then..
			setTimeout(f, 1); //..then call the function again after 100 milliseconds
		}else{ //otherwise..
			obj.style.display = 'none'; //..otherwise now that we cant see the element anyways, hide it
		}
	}
	setTimeout(f, 100); //This is where we call the f() function for the first time



	document.getElementById(domId+"_t").innerHTML='<a class="'+str1+'colaps_t" href="#" onMouseover="javascript:appear(\''+domId+'\',\''+str1+'\');"></a>';


};

function appear2(domId){
	obj = document.getElementById(domId); //Get the element
	if(obj.style.display != "none") return false; //Return if it is already being displayed
	obj.style.display = ''; //Un-hide the object before its animation
	var alpha = 0; //Set the initial value of alpha to 0 (invisible)
	function a(){ //Internal function
		alpha++; //Increment alpha
		setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
		if(alpha < 11)setTimeout(a, 10);
		/*Till alpha is 10, keep calling the
		a() function after 100 milliseconds */
	}
	setTimeout(a, 1); //This is where we call the a() function for the first time

	document.getElementById(domId+"_t").innerHTML='<a class="colaps" href="#" onMouseout="javascript:fade(\''+domId+'\');"></a>';
};


/*
koj custom ajax
*/

function printpage(printurl,printtitle,printfeatures)
{
	window.open(printurl,printtitle,printfeatures);
}
function sendmailto(str1,str2)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}

	var from_name_val=encodeURIComponent(document.getElementById("from_name").value);
	var from_mail_val=encodeURIComponent(document.getElementById("from_mail").value);
	var to_name_val=encodeURIComponent(document.getElementById("to_name").value);
	var to_mail_val=encodeURIComponent(document.getElementById("to_mail").value);
	var message_val=encodeURIComponent(document.getElementById("message").value);
	var code_val=encodeURIComponent(document.getElementById("code").value);
	var parameters="from_name="+from_name_val+"&from_mail="+from_mail_val+"&to_name="+to_name_val+"&to_mail="+to_mail_val+"&message="+message_val+"&code="+code_val;
	xmlHttp.onreadystatechange=sendmailtoChanged;
	xmlHttp.open("POST", siteurl+"frontend/preview/sendmail/"+str1+"/"+str2+"/1", true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.send(parameters);
}

function sendmailtoChanged()
{
	document.getElementById("mail_submit_result").innerHTML=xmlHttp.responseText;
}

function catChanged1(str1,str2)
{
	document.getElementById("cat_"+str1).innerHTML='<a href="'+"javascript:catChanged2('"+str1+"','"+str2+"');"+'">'+str2+"</a>";
	document.getElementById("progcatjs").innerHTML="ie6_hack<style>#progcat_"+str1+"{display:block;overflow:visible;height:100%;}</style>";
}

function catChanged2(str1,str2)
{
	document.getElementById("cat_"+str1).innerHTML='<a href="'+"javascript:catChanged1('"+str1+"','"+str2+"');"+'">'+str2+"</a>";
	document.getElementById("progcatjs").innerHTML="ie6_hack";
}

function ajaxloader_b(str1)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url=str1;
	xmlHttp.onreadystatechange=ajaxloader_bChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function ajaxloader_bChanged()
{
	document.getElementById("previewdesc2").innerHTML=xmlHttp.responseText;
}

function ajaxloader_bClose()
{
	document.getElementById("previewdesc2").innerHTML="";
}

function ajaxloader_cClose()
{
	document.getElementById("previewdesc3").innerHTML="";
}

function ajaxloader_a(str1)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url=str1;
	xmlHttp.onreadystatechange=ajaxloader_aChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function ajaxloader_aChanged()
{
	document.getElementById("previewdesc").innerHTML=xmlHttp.responseText;
}

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;
}