/**
	@author tGDA
	Used to switch between available styles 
*/

StyleSwitcher={};
StyleSwitcher.avaiableStylesheets=[];
StyleSwitcher.hiddenStyleImg=null;
StyleSwitcher.extraImages2preload=['meeting_name.gif', 'top_bg.gif', 'logo.gif'];
StyleSwitcher.init=function() {
	var maybeStylesheets=document.getElementsByTagName('link');
	for(var i=0; i<maybeStylesheets.length; i++) {
		var currElem=maybeStylesheets[i], name;
		if(currElem.getAttribute('rel').indexOf('stylesheet')!=-1 &&(name=currElem.getAttribute('title'))) {
			this.avaiableStylesheets[name]=currElem;
			//alert(this.avaiableStylesheets[name]);
			
			/*for(var k=0; k<this.extraImages2preload.length; k++){
				(new Image()).src='./Templates/Acnc/'+name+'/'+StyleSwitcher.extraImages2preload[k];
			}*/
		}
	}
	this.hiddenStyleImg=document.createElement('IMG');
	this.hiddenStyleImg.id='style-hidden-img-switch';
	this.hiddenStyleImg.width='0';
	this.hiddenStyleImg.hieght='0';
	document.body.appendChild(this.hiddenStyleImg);
}

StyleSwitcher.setActiveStylesheet=function(newStylesheet) {
	var found=false;
	for(var i in this.avaiableStylesheets) {
		//alert(i);
		var styleElem=this.avaiableStylesheets[i];
		//alert(styleElem);
		styleElem.disabled=true;
			
		if(i==newStylesheet) {
			found=true;
			styleElem.rel='stylesheet';
			styleElem.disabled=false;
			this.hiddenStyleImg.src='utils.php?do=changestyle&newstyle='+i;
		} else {
			//styleElem.rel='alternate stylesheet';
		}
	}
	
	if(!found) {
		alert('no such style');
	}
}


	var gAutoPrint = true; 
	function printSpecial()
	{
		if (document.getElementById != null)
		{
		
			var html = '<HTML dir=rtl>\n<HEAD>\n';
		
			/*if (document.getElementsByTagName != null)
			{
				var headTags = document.getElementsByTagName("head");
				if (headTags.length > 0)
				html += headTags[0].innerHTML;
			}*/
		
			html += '<META http-equiv=Content-Type content=\"text/html; charset=utf-8\"><LINK href=\"Templates/Acnc/style.css\" rel=stylesheet></LINK><LINK href=\"Templates/Acnc/rtl.css\" type=text/css rel=stylesheet>\n</HEAD>\n<BODY style=\"background-color:#FFFFFF;color:#0000\">\n ';
						html += '<table width=\"760\" align=\"center\"><tr><td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"line-height:150%\"><tr><td align=\"right\" style=\"padding-right:31px; padding-top:2px\" width=\"100\" ><span class=\"header_logo\"><a href=\"index.php\" class=\"header_logo\" ><img src=\"Templates/Acnc/images/logo.gif\" alt=\"المحتوى الرقمي العربي\" title=\"المحتوى الرقمي العربي\" class=\"noimg\" border=0 align=\"absbottom\"></a> </span></td> <td align=\"right\" valign=\"top\"><span class=\"header_logo\"> <a href=\"index.php\" class=\"header_logo\" > </a></span> <table width=\"450\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td colspan=\"2\" align=\"center\"> <span class=\"header_logo\"><a href=\"index.php\" class=\"header_logo\" >المؤتمر الوطني الأول لصناعة المحتوى الرقمي العربي</a></span></td></tr> <tr> <td colspan=\"2\" align=\"center\"><span class=\"header_slogo\" >وزارة الإعلام ـ وزارة الاتصالات والتقانة ـ الجمعية العلمية السورية للمعلوماتية </span><br><span class=\"header_slogos\">بالتعاون مع اللجنة الوطنية للتربية والثقافة والعلوم</span></td></tr><tr><td width=\"60%\" style=\"padding-right:10px;\"align=\"center\"><span class=\"header_slogos\">الجمهورية العربية السورية ـ دمشق</span></td><td align=\"right\"><span class=\"header_slogo\">13ـ 15 حزيران 2009</span></td></tr></table></td></tr></table><br><br>';
			
			html += '<table width=\"760\" align=\"center\"><tr><td style=\"text-align:justify;direction:rtl;font-color:#000;\">';
			var printReadyElem = document.getElementById("printReady");

			if (printReadyElem != null)
			{
				html += printReadyElem.innerHTML;
			}
			else
			{
				alert("");
				return;
			}

			html += '\n</br>';
			html += '<span style=font-family:Arial;font-size:10px; ><div align=left>Copyright © 2009, ACNC. All Rights Reserved</div></span></td></tr></table></body></html>'; 

			//var printWin = window.open("","printSpecial");
			var printWin = window.open('','mywindow','width=800,height=600,scrollbars=yes,toolbar=yes,location=yes,menubar=yes,directories=yes,resizable=1');
			printWin.document.open();
    		//printWin.document.write(' ');
			//printWin.document.write('');
			printWin.document.write(html);
			//printWin.document.write('');
			printWin.document.close();
			
			if (gAutoPrint)
			printWin.print();
		}
		else
		{
			alert("");
		}
	}

		function changeFont (newFont, fontName)
		{
			var spans = document.getElementsByTagName ("span");
			for (var index = 0; index < spans.length; index ++)
			{
				
				if (spans [index].className.indexOf ("small_font") != -1)
				{
					
					spans [index].style.fontSize = newFont + "px";
				}
				else
				if (spans [index].className.indexOf ("large_font") != -1 || spans [index].className == "" )
				{
					spans [index].style.fontSize = (parseInt(newFont) + 1) + "px";
				}
			}
			
			var ps = document.getElementsByTagName ("p");
			
			for (var index = 0; index < ps.length; index ++)
			{
				
				if (ps [index].className.indexOf ("small_font") != -1 )
				{
					ps [index].style.fontSize = newFont + "px";
				}
				else
				if (ps [index].className.indexOf ("large_font") != -1 || ps [index].className == "" )
				{
					ps [index].style.fontSize = (parseInt(newFont) + 1) + "px";
				}
			}
			
			setCookie ("font", fontName, 365);			
		} 
		function setCookie(c_name,value,expiredays)
		{
			var exdate = new Date();
			exdate.setDate(exdate.getDate()+expiredays);
			document.cookie=c_name+ "=" +escape(value)+
			((expiredays==null) ? "" : ";expires=" + exdate.toGMTString());
		}
	function fun_res(tt)
	{
		if(tt)
		{
			var ifamenewh = window.frames['mainiframe'].document.getElementById('c_main_table').offsetHeight;		
			ifamenewh = parseInt(ifamenewh)+120;					
			document.getElementById('mainiframe').style.height = ifamenewh+'px';
			document.getElementById('mainiframe').style.width = '100%';
		}	
		
	}