function CheckChannel(){
	var frm;
		frm = document.getElementById('frmchannels');
		if(frm.global___channelname.value == ''){alert("נא לרשום שם הערוץ");frm.global___channelname.focus();return false;}
	frm.submit();
}

function ClipBoard() 
{
	channelcode.innerText = channelcodetemp.innerText;
	Copied = channelcode.createTextRange();
	Copied.execCommand("Copy");


	alert("קטע קוד הועתק לזכרון, נא הדביקו את הקוד באזור הרצוי");
}
/*
function PreviewChannel()
{
	alert("PreviewChannel");
}
*/
function CreatePreview()
{
	/*
	mainadds_preview = main border of all table
	title_preview = first row, title
	desc_preview = second and third rows
	link_preview = the last (and) link 
	*/
	var ObjForm = document.getElementById("frmprew");
	var Objglobal___bordercolor = document.getElementById("global___bordercolor");
	var Objglobal___backgroundcolor = document.getElementById("global___backgroundcolor");
	var Objglobal___linedescription = document.getElementById("global___linedescription");
	var Objglobal___lineurl = document.getElementById("global___lineurl");
	var Objglobal___linetitle = document.getElementById("global___linetitle");
	
	// Create default values
	if(Objglobal___bordercolor.value==''){Objglobal___bordercolor.value = "#000000"; }
	if(Objglobal___backgroundcolor.value==''){Objglobal___backgroundcolor.value = "#FFFFFF"; }
	if(Objglobal___linedescription.value==''){Objglobal___linedescription.value = "#000000"; }
	if(Objglobal___lineurl.value==''){Objglobal___lineurl.value = "#000000"; }
	if(Objglobal___linetitle.value==''){Objglobal___linetitle.value = "#000000"; }
	
	var Objglobal___lineurl = document.getElementById("global___lineurl");
		document.getElementById("mainadds_preview").style.borderColor = Objglobal___bordercolor.value;
		document.getElementById("mainadds_preview").style.backgroundColor = Objglobal___backgroundcolor.value;
		
		document.getElementById("link_preview1").style.color = Objglobal___lineurl.value;
		document.getElementById("link_preview2").style.color = Objglobal___lineurl.value;
		document.getElementById("link_preview3").style.color = Objglobal___lineurl.value;
		
		document.getElementById("desc_preview1").style.color = Objglobal___linedescription.value;
		document.getElementById("desc_preview2").style.color = Objglobal___linedescription.value;
		document.getElementById("desc_preview3").style.color = Objglobal___linedescription.value;
		
		document.getElementById("title_preview1").style.color = Objglobal___linetitle.value;
		document.getElementById("title_preview2").style.color = Objglobal___linetitle.value;
		document.getElementById("title_preview3").style.color = Objglobal___linetitle.value;
		
		document.getElementById("sitemane_preview").style.color = Objglobal___linetitle.value;
		
}




function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}


function LoadAds(id_adds,id_channel,filladds)
{
	//var FrmObj = document.getElementById(textarea);
	var SentToPage="Ajax/load_ads.php";
	var browsertype = getBrowserType();
		xmlStr="?id_adds="+encodeURIComponent(id_adds)+"&id_channel="+encodeURIComponent(id_channel);
		SentToPageInner = SentToPage+xmlStr;
		//alert(SentToPageInner);
		if(browsertype=='ff'){
			xmlObj = new XMLHttpRequest();
		} else {
			xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
			
		}

		xmlObj.open ("GET", SentToPageInner ,false);
		xmlObj.send(null);
		
		var responseText = xmlObj.responseText;
		xmlObj.Close;
		xmlObj = null;
		
		document.getElementById(filladds).innerHTML = responseText;
}


function RemoveAds(id_channel,id_adds,id_user,id_adds_banner)
{
	var SentToPage="Ajax/remove_ads.php";
	var browsertype = getBrowserType();
		xmlStr="?id_channel="+encodeURIComponent(id_channel);
		xmlStr+="&id_adds="+encodeURIComponent(id_adds);
		xmlStr+="&id_user="+encodeURIComponent(id_user);
		xmlStr+="&id_adds_banner="+encodeURIComponent(id_adds_banner);
		SentToPageInner = SentToPage+xmlStr;
		//alert(SentToPageInner);
		if(browsertype=='ff'){
			xmlObj = new XMLHttpRequest();
		} else {
			xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
			
		}

		xmlObj.open ("GET", SentToPageInner ,false);
		xmlObj.send(null);	
		
		var responseText = trim(xmlObj.responseText);
		xmlObj.Close;
		xmlObj = null;
		
		if(responseText=='OK'){
			alert("באנר הוסר בהצלחה מהערוץ הנוכחי");
		}
		else if (responseText=='REMOVED')
		{
			alert("באנר נוכחי כבר הוסר מהערוץ");
		}
		else
		{
			alert(responseText);
		}
}




function AddAds(id_channel,id_adds,id_user,id_adds_banner)
{
	//var FrmObj = document.getElementById(textarea);
	var SentToPage="Ajax/add_ads.php";
	var browsertype = getBrowserType();
		xmlStr="?id_channel="+encodeURIComponent(id_channel);
		xmlStr+="&id_adds="+encodeURIComponent(id_adds);
		xmlStr+="&id_user="+encodeURIComponent(id_user);
		xmlStr+="&id_adds_banner="+encodeURIComponent(id_adds_banner);
		SentToPageInner = SentToPage+xmlStr;
		//alert(SentToPageInner);
		if(browsertype=='ff'){
			xmlObj = new XMLHttpRequest();
		} else {
			xmlObj = new ActiveXObject("Msxml2.XMLHTTP");
			
		}

		xmlObj.open ("GET", SentToPageInner ,false);
		xmlObj.send(null);	
		
		var responseText = trim(xmlObj.responseText);
		xmlObj.Close;
		xmlObj = null;
		
		if(responseText=='OK'){
			alert("באנר נכנס בהצלחה לערוץ הנוכחי");
		}
		else if (responseText=='EXIST')
		{
			alert("באנר נוכחי כבר קיים בערוץ");
		}
		/*
		else
		{
			alert(responseText);
		}
		*/
}