﻿﻿// constants
var NORMAL_STATE = 4;
var domainroot="/";
var ax = 'php/turing/emailarticle.php';

// set the language code of javascript

var languageCode = "";
/*
var currentUrlArray = document.URL.split('/');
for(var i=currentUrlArray.length-1; i>0; i--){
	var currentArrayElem = currentUrlArray[i];
	if(currentArrayElem.match(/en/) || currentArrayElem.match(/ar/) || currentArrayElem.match(/fa/) || currentArrayElem.match(/ku/) ){
		languageCode = currentArrayElem;
		break;
	}
}
*/


// "click to activate this control" fix for Internet Explorer
function runLoadFlash(docRoot1, flashComp1){

	var flashComp = flashComp1;
	var docRoot = docRoot1;
	var myObjString = "";
//	var languageCd = arguments[2];
	
//	var mwvVideoGalleryString = "<OBJECT id='mediaPlayer' width=\"320\" height=\"255\""; 
//		mwvVideoGalleryString += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'"; 
//		mwvVideoGalleryString += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'";
//		mwvVideoGalleryString += "standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
//		mwvVideoGalleryString += "<param name='fileName' value=\""+ videoFilePath +">";
//		mwvVideoGalleryString += "<param name='animationatStart' value='true'>";
//		mwvVideoGalleryString += "<param name='transparentatStart' value='false'>";
//		mwvVideoGalleryString += "<param name='autoStart' value=\"true\">";
//		mwvVideoGalleryString += "<param name='showControls' value=\"true\">";
//		mwvVideoGalleryString += "<param name='loop' value=\"false\">";
//		mwvVideoGalleryString += "<EMBED type='application/x-mplayer2'";
//		mwvVideoGalleryString += " pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'";
//		mwvVideoGalleryString +=  " id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'"; 
//		mwvVideoGalleryString +=  " bgcolor='darkblue' showcontrols=\"true\" showtracker='-1'"; 
//		mwvVideoGalleryString +=  " showdisplay='0' showstatusbar='-1' videoborder3d='-1' width=\"320\" height=\"255\"";
//		mwvVideoGalleryString +=  " src=\""+ videoFilePath +"\" autostart=\"false\" designtimesp='5311' loop=\"false\">";
//		mwvVideoGalleryString += "</EMBED>";
//		mwvVideoGalleryString += "</OBJECT>";
	
//	alert("docRoot = " + docRoot + " flashComp = " + flashComp);
	
	
	switch(flashComp)
	{
//		case 'flashPoll':
//		
//			var pollString = '<div id="fivepxbordertop">';
//			pollString += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="179" height="340" id="demo" align="middle">';
//			pollString += '<param name="allowScriptAccess" value="sameDomain" />';
//			pollString += '<param name="FlashVars" value="pollXML='+docRoot+'includes/php/polls/poll.xml">';
//			pollString += '<param name="movie" value="'+docRoot+'includes/php/polls/poll.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#27488f" />';
//			pollString += '<embed src="'+docRoot+'includes/php/polls/poll.swf" FlashVars="pollXML='+docRoot+'includes/php/polls/poll.xml" quality="high" bgcolor="#27488f" width="179" height="340" name="demo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
//			pollString += '</object>';
//			pollString += '</div>';
//			myObjString = pollString;
//			break;
//		
		case 'flashPhotoOfDay':
		
			var photoOfDayString = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="410" height="298" id="index" align="middle">';
			photoOfDayString += '<param name="allowScriptAccess" value="sameDomain" />';
			photoOfDayString += '<param name="movie" value="'+docRoot+'photo_of_day/index.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="'+docRoot+'photo_of_day/index.swf" quality="high" bgcolor="#ffffff" width="410" height="298" name="demo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			photoOfDayString += '</object>';
			myObjString = photoOfDayString;
			break;
		case 'flashIraqiSecForces':

			var IraqiSecForcesString = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="410" height="298" id="index" align="middle">';
			IraqiSecForcesString += '<param name="allowScriptAccess" value="sameDomain" />';
			IraqiSecForcesString += '<param name="movie" value="'+docRoot+'iraqi_sec_forces/index.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="'+docRoot+'iraqi_sec_forces/index.swf" quality="high" bgcolor="#ffffff" width="410" height="298" name="demo" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			IraqiSecForcesString += '</object>';
			myObjString = IraqiSecForcesString;
			break;	
			
		case 'flashVideoGallery':
		
			var videoGalleryString = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="500" height="363" id="movieTest" align="middle">';
			videoGalleryString += '<param name="allowScriptAccess" value="sameDomain" />';
			videoGalleryString += '<param name="movie" value="movieTest.swf" /><param name="quality" value="medium" /><param name="bgcolor" value="#ffffff" /><embed src="movieTest.swf" quality="medium" bgcolor="#ffffff" width="500" height="363" name="movieTest" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			videoGalleryString += '</object>';
			myObjString = videoGalleryString;
			break;
			
		case 'mwvVideoGallery':
        
			var mwvVideoGalleryString = "<OBJECT id='mediaPlayer' width=\"320\" height=\"255\""; 
			mwvVideoGalleryString += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'"; 
			mwvVideoGalleryString += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'";
			mwvVideoGalleryString += "standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
			mwvVideoGalleryString += "<param name='fileName' value=\""+docRoot+"multimedia/videos/mujahideenGM/AKArobics.wmv\">";
			mwvVideoGalleryString += "<param name='animationatStart' value='true'>";
			mwvVideoGalleryString += "<param name='transparentatStart' value='false'>";
			mwvVideoGalleryString += "<param name='autoStart' value=\"true\">";
			mwvVideoGalleryString += "<param name='showControls' value=\"true\">";
			mwvVideoGalleryString += "<param name='loop' value=\"false\">";
			mwvVideoGalleryString += "<EMBED type='application/x-mplayer2'";
			mwvVideoGalleryString += " pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'";
			mwvVideoGalleryString +=  " id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'"; 
			mwvVideoGalleryString +=  " bgcolor='darkblue' showcontrols=\"true\" showtracker='-1'"; 
			mwvVideoGalleryString +=  " showdisplay='0' showstatusbar='-1' videoborder3d='-1' width=\"320\" height=\"255\"";
			mwvVideoGalleryString +=  " src=\""+docRoot+"multimedia/videos/mujahideenGM/AKArobics.wmv\" autostart=\"true\" designtimesp='5311' loop=\"false\">";
			mwvVideoGalleryString += "</EMBED>";
			mwvVideoGalleryString += "</OBJECT>";
			myObjString = mwvVideoGalleryString;
			break;	
				
		case 'mwvBulletVideo_hi_en':
			
			var mwvVideoGalleryString = "<OBJECT id='mediaPlayer' width=\"320\" height=\"255\""; 
			mwvVideoGalleryString += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'"; 
			mwvVideoGalleryString += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'";
			mwvVideoGalleryString += "standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
			mwvVideoGalleryString += "<param name='fileName' value=\""+docRoot+"multimedia/videos/bulletVideo/English112K_Stream.wm\">";
			mwvVideoGalleryString += "<param name='animationatStart' value='true'>";
			mwvVideoGalleryString += "<param name='transparentatStart' value='false'>";
			mwvVideoGalleryString += "<param name='autoStart' value=\"true\">";
			mwvVideoGalleryString += "<param name='showControls' value=\"true\">";
			mwvVideoGalleryString += "<param name='loop' value=\"false\">";
			mwvVideoGalleryString += "<EMBED type='application/x-mplayer2'";
			mwvVideoGalleryString += " pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'";
			mwvVideoGalleryString +=  " id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'"; 
			mwvVideoGalleryString +=  " bgcolor='darkblue' showcontrols=\"true\" showtracker='-1'"; 
			mwvVideoGalleryString +=  " showdisplay='0' showstatusbar='-1' videoborder3d='-1' width=\"320\" height=\"285\"";
			mwvVideoGalleryString +=  " src=\""+docRoot+"multimedia/videos/bulletVideo/English112K_Stream.wmv\" autostart=\"true\" designtimesp='5311' loop=\"false\">";
			mwvVideoGalleryString += "</EMBED>";
			mwvVideoGalleryString += "</OBJECT>";
			myObjString = mwvVideoGalleryString;
			break;
			
	    case 'mwvBulletVideo_low_en':
       
	    	var mwvVideoGalleryString = "<OBJECT id='mediaPlayer' width=\"320\" height=\"255\""; 
	    	mwvVideoGalleryString += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'"; 
	    	mwvVideoGalleryString += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'";
	 		mwvVideoGalleryString += "standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
	   		mwvVideoGalleryString += "<param name='fileName' value=\""+docRoot+"multimedia/videos/bulletVideo/English56K_Dial_Up_Stream.wmv\">";
	   		mwvVideoGalleryString += "<param name='animationatStart' value='true'>";
	   		mwvVideoGalleryString += "<param name='transparentatStart' value='false'>";
	   		mwvVideoGalleryString += "<param name='autoStart' value=\"true\">";
	   		mwvVideoGalleryString += "<param name='showControls' value=\"true\">";
	   		mwvVideoGalleryString += "<param name='loop' value=\"false\">";
	   		mwvVideoGalleryString += "<EMBED type='application/x-mplayer2'";
	   		mwvVideoGalleryString += " pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'";
	   		mwvVideoGalleryString +=  " id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'"; 
	   		mwvVideoGalleryString +=  " bgcolor='darkblue' showcontrols=\"true\" showtracker='-1'"; 
	   		mwvVideoGalleryString +=  " showdisplay='0' showstatusbar='-1' videoborder3d='-1' width=\"320\" height=\"285\"";
	   		mwvVideoGalleryString +=  " src=\""+docRoot+"multimedia/videos/bulletVideo/English56K_Dial_Up_Stream.wmv\" autostart=\"true\" designtimesp='5311' loop=\"false\">";
	   		mwvVideoGalleryString += "</EMBED>";
	   		mwvVideoGalleryString += "</OBJECT>";
	   		myObjString = mwvVideoGalleryString;
	   		break;
	
		case 'mwvBulletVideo_hi_ar':
        
			var mwvVideoGalleryString = "<OBJECT id='mediaPlayer' width=\"320\" height=\"255\""; 
			mwvVideoGalleryString += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'"; 
			mwvVideoGalleryString += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'";
			mwvVideoGalleryString += "standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
			mwvVideoGalleryString += "<param name='fileName' value=\""+docRoot+"multimedia/videos/bulletVideo/spedbul_hi_ar.wmv\">";
			mwvVideoGalleryString += "<param name='animationatStart' value='true'>";
			mwvVideoGalleryString += "<param name='transparentatStart' value='false'>";
			mwvVideoGalleryString += "<param name='autoStart' value=\"true\">";
			mwvVideoGalleryString += "<param name='showControls' value=\"true\">";
			mwvVideoGalleryString += "<param name='loop' value=\"false\">";
			mwvVideoGalleryString += "<EMBED type='application/x-mplayer2'";
			mwvVideoGalleryString += " pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'";
			mwvVideoGalleryString +=  " id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'"; 
			mwvVideoGalleryString +=  " bgcolor='darkblue' showcontrols=\"true\" showtracker='-1'"; 
			mwvVideoGalleryString +=  " showdisplay='0' showstatusbar='-1' videoborder3d='-1' width=\"320\" height=\"285\"";
			mwvVideoGalleryString +=  " src=\""+docRoot+"multimedia/videos/bulletVideo/spedbul_hi_ar.wmv\" autostart=\"true\" designtimesp='5311' loop=\"false\">";
			mwvVideoGalleryString += "</EMBED>";
			mwvVideoGalleryString += "</OBJECT>";
			myObjString = mwvVideoGalleryString;
			break;
        
		case 'mwvBulletVideo_low_ar':
        
			var mwvVideoGalleryString = "<OBJECT id='mediaPlayer' width=\"320\" height=\"255\""; 
			mwvVideoGalleryString += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'"; 
			mwvVideoGalleryString += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'";
			mwvVideoGalleryString += "standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
			mwvVideoGalleryString += "<param name='fileName' value=\""+docRoot+"multimedia/videos/bulletVideo/spedbul_low_ar.wmv\">";
			mwvVideoGalleryString += "<param name='animationatStart' value='true'>";
			mwvVideoGalleryString += "<param name='transparentatStart' value='false'>";
			mwvVideoGalleryString += "<param name='autoStart' value=\"true\">";
			mwvVideoGalleryString += "<param name='showControls' value=\"true\">";
			mwvVideoGalleryString += "<param name='loop' value=\"false\">";
			mwvVideoGalleryString += "<EMBED type='application/x-mplayer2'";
			mwvVideoGalleryString += " pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'";
			mwvVideoGalleryString +=  " id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'"; 
			mwvVideoGalleryString +=  " bgcolor='darkblue' showcontrols=\"true\" showtracker='-1'"; 
			mwvVideoGalleryString +=  " showdisplay='0' showstatusbar='-1' videoborder3d='-1' width=\"320\" height=\"285\"";
			mwvVideoGalleryString +=  " src=\""+docRoot+"multimedia/videos/bulletVideo/spedbul_low_ar.wmv\" autostart=\"true\" designtimesp='5311' loop=\"false\">";
			mwvVideoGalleryString += "</EMBED>";
			mwvVideoGalleryString += "</OBJECT>";
			myObjString = mwvVideoGalleryString;
			break;	
		
		case 'gam_soccer':
        
			var mwvVideoGalleryString = '<div id="jugglingGameDiv">';
			mwvVideoGalleryString += '<embed '; 
			mwvVideoGalleryString += 'width="398" '; 
			mwvVideoGalleryString += 'height="348" '; 
			mwvVideoGalleryString += 'src="'+docRoot+'multimedia/games/juggling.swf" '; 
			mwvVideoGalleryString += 'quality="high" '; 
			mwvVideoGalleryString += 'pluginspage="http://www.macromedia.com/go/getflashplayer" '; 
			mwvVideoGalleryString += 'type="application/x-shockwave-flash">';
			mwvVideoGalleryString += '</embed>';
			mwvVideoGalleryString += '</div>';
			myObjString = mwvVideoGalleryString;
			break;
		
//		case 'gam_penaltyShootout':
//        
//			var mwvVideoGalleryString = '<div id="penaltyShootoutDiv">';
//			mwvVideoGalleryString += '<embed '; 
//			mwvVideoGalleryString += 'width="408" '; 
//			mwvVideoGalleryString += 'height="304" '; 
//			mwvVideoGalleryString += 'src="'+docRoot+'multimedia/games/PenaltyShootout.swf" '; 
//			mwvVideoGalleryString += 'quality="high" '; 
//			mwvVideoGalleryString += 'pluginspage="http://www.macromedia.com/go/getflashplayer" '; 
//			mwvVideoGalleryString += 'type="application/x-shockwave-flash">';
//			mwvVideoGalleryString += '</embed>';
//			mwvVideoGalleryString += '</div>';
//			myObjString = mwvVideoGalleryString;
//			break;									
	}
//	alert(myObjString);
	if(arguments.length > 2){
		return myObjString;
	}
	else{
		document.write(myObjString);
	}	
	
	
//	alert("myObjString = " + myObjString);

}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//switches news tabs
function switchTab(tab, curFeed){

	if(tab.substr(0,6) == 'closed'){
		
		el = document.getElementById(tab);
	
		newsTab = document.getElementById("newsTabs");
		listItems = newsTab.getElementsByTagName("li");
	
		//loop through news tab and close all that are open
	
		for(i = 0; i < listItems.length;i++){
		
			if(listItems[i].id == 'opened' + (i + 1)){
				listItems[i].id = "closed" + (i + 1);
				document.getElementById("newsFeed" + (i + 1)).style.display = "none";
			}
		}				
		el.id = "opened" + tab.substr(tab.length - 1);
		curFeed.id = "newsFeed" + tab.substr(tab.length - 1);
		document.getElementById("newsFeed" + tab.substr(tab.length - 1)).style.display = "block";
	}
}
//Javascript to deal with forms

function grabTitlePutInCommentsHiddenTitle(subType){

	var thisTitle = jQuery("div.articleHeader").html();
	if (!thisTitle)
	{
		thisTitle = jQuery("div#content h1").html();
		if (thisTitle)
		{
			var strCopy = thisTitle.toLowerCase();
			thisTitle = thisTitle.substring(0,strCopy.indexOf("<p"));
		}
		else 
		{
			thisTitle = "This content does not have a title.";
		}	
	}
	if(subType == "emailArticle"){
		jQuery("div#content #ef_hiddenTitle").val(thisTitle);
	}else{
		jQuery("div#content #hiddenTitle").val(thisTitle);
	}
}

function getData(dataSource, dataPost){ 
//	alert("in the getData function");
  	var XMLHttpRequestObject = false; 	

  	if (window.XMLHttpRequest) {
    	XMLHttpRequestObject = new XMLHttpRequest();
  	}else if (window.ActiveXObject) {
    	XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  	}
  	if(XMLHttpRequestObject) {
    	XMLHttpRequestObject.open("POST", dataSource);
 		XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

    	XMLHttpRequestObject.onreadystatechange = function() {
//			alert("onreadystate = " + XMLHttpRequestObject.readyState); 
      		if (XMLHttpRequestObject.readyState == 4){
//				alert("http status = " + XMLHttpRequestObject.status);
				if (XMLHttpRequestObject.status == 200 || XMLHttpRequestObject.status == 304) {
					checkEmailResponse(XMLHttpRequestObject.responseText);
					delete XMLHttpRequestObject;
					XMLHttpRequestObject = null;
				}else{
//					alert("Error conecting to server: Please submit your request again.");
//					alert("readyState = " + XMLHttpRequestObject.readyState + " http status = " + XMLHttpRequestObject.status);
				}	
      		}//end of readystate check if
    	} 
    	XMLHttpRequestObject.send(dataPost); 
  	}
}
function checkEmailResponse(emailResponse){
//	alert(emailResponse)
	
	if(emailResponse.match(/not match/)){
		jQuery('#error').text('The digits you entered do not match the ones in the image.');
		return;		
	}else{
		jQuery('#emailFormDiv').jqmHide();
		return;
	}
	
	var resp = emailResponse.split('+');
	if(resp[0] == 'success'){
		switch(resp[1]){
			case 'en':
				textout = "Dear Viewer,<br><br> Thank you for your comments regarding mawtani.com. <br>We appreciate your viewpoint as we continue to make improvements to our website.";
			break;
			case 'ar':
				textout = "اعزائنا الزوار الكرام،<br>شكرا لتعليقاتكم حول موقع موطني. <br>نحن نقدّر وجهة نظركم ونواصل اجراء التحسينات لموقعنا. <br><br>العاملون بموقع موطني";
			break;
			case 'fa':
				textout = "خواننده گرامی؛<br><br>از اینکه نظر خود را درباره سایت موطنی به اطلاع ما رساندید، از شما سپاسگزاریم. ما از نقطه نظرهای شما که ما را  در جهت بهبود کیفیت این پایگاه اینترنتی یاری می کند، قدردانی می کنیم. <br>کارکنان پایگاه اینترنتی موطنی";
			break;
			case "ku":
				textout = "میوانه‌ به‌ڕێزه‌کان، <br>سوپاس بۆ تێبینیه‌کانتان ده‌رباره‌ی ماڵپه‌ڕی مه‌وتنی. بۆچونه‌کانتان به‌رز ده‌نرخێنین و به‌رده‌وامین له‌ گرتنه‌به‌ری هه‌نگاوه‌کان بۆ به‌ره‌وپێشبردنی ماڵپه‌ڕه‌که‌مان.<br>کارمه‌ندانی مه‌ڵپه‌ڕی مه‌وتنی";
			break;
		}
//		document.getElementById('contactForm').innerHTML = textout;
		if(resp[2] != "emailArticle"){
			document.getElementById('contactForm').innerHTML = textout;
		}else{
			//clean up form and close dialogue
			jQuery('div#emailFormDiv form :input').each(function(){
				var type = this.type;
				var tag = this.tagName.toLowerCase();
				if (type == 'text' || tag == 'textarea' || type == 'hidden'){
					this.value = "";
				}	
			});
			jQuery('#emailFormDiv').jqmHide();
		}
	}else{
		switch(resp[1]){
			case 'en':
				textout = "There was an error with your submission.  Please try again.";
			break;
			case 'ar':
				textout = "هناك خطأ في الارسال يرجى المحاولة مرة ثانية";
			break;
			case 'fa':
				textout = "ارسال اظهار نظر شما با مشکل روبرو شد. لطفا مجددا ارسال بفرمایید. ";
			break;
			case "ku":
				textout = "کێشه‌ هه‌یه‌ له‌ناردنی په‌یامه‌که‌ت، تکایه‌ جارێکی تر هه‌وڵبده";
			break;
		}
		if (resp[2] != "emailArticle") {
			document.getElementById('error').innerHTML = textout;
		}else{
			document.getElementById('ef_error').innerHTML = textout;
		}		
	}
}
function checkForm(type, curURL, formName, required, root){
	
	var fields = required.split('+');
	var failed = 0;
	
	for(i = 0; i < fields.length;i++){

		document.getElementById(fields[i]).style.color = "#000000";

		if(formName[fields[i]].value == ''){

			document.getElementById(fields[i]).style.color = "#cc0000";
			failed = 1;
		}else{
			document.getElementById(fields[i]).style.color = "#000000";
		}
		if(fields[i]=="ef_emailto"){
			var emailAddresses = formName.ef_emailto.value;
			var emailAddressesArray = emailAddresses.split(",");
			if(emailAddressesArray.length > 5){
				document.getElementById(fields[i]).style.color = "#cc0000";
				document.getElementById('emailRestrictions').style.color = "#cc0000";
				failed = 1;
			}else{
				document.getElementById('emailRestrictions').style.color = "#000000";
			}
		}
		if(fields[i]=="digits" || fields[i]=="ef_digits"){
			if(formName[fields[i]].value.length != 5){
				document.getElementById(fields[i]).style.color = "#cc0000";
				failed = 1;
			}
		}
	}

	//alert("Failed value = " + failed);
	if(failed == 0){
		ugcSubmmission(formName, root, type, curURL);
	}
}

function ugcSubmmission(formName, root, type, url){
	var subType = type.substr(0,type.indexOf(' -'));
//	alert(subType);
	grabTitlePutInCommentsHiddenTitle(subType);
	if(subType == "emailArticle"){
		var s = 'name='+encodeURIComponent(formName.nameField.value);
		s+= '&email=yes';
		s+= '&emailTo='+encodeURIComponent(formName.ef_emailto.value);
		s+= '&emailMessage='+encodeURIComponent(formName.ef_comments.value);
		s+= '&emailName='+encodeURIComponent(formName.nameField.value);;
		s+= '&ajax=yes'
		s+= '&userdigits='+encodeURIComponent(formName.ef_digits.value);
		s+= '&emailID='+encodeURIComponent(formName['id'].value);
		s+= '&emailLang='+encodeURIComponent(formName.lang.value);
		s+= '&emailURL='+encodeURIComponent(window.location);
		s+= '&emailSubject='+encodeURIComponent(jQuery('input[name=emailSubject]').val())
		s+= '&emailTitle='+encodeURIComponent(document.title);	
		s+= '&site='+encodeURIComponent(formName.site.value);
		//alert(s);	
	}else{
		s = 'name='+encodeURIComponent(formName.nameField.value)+'&email='+encodeURIComponent(formName.email.value);
		s+= '+&comments='+encodeURIComponent(formName.comments.value)+'&digits='+encodeURIComponent(formName.digits.value);
		s+= '+&reqType=UGC&type='+encodeURIComponent(type)+'&url='+encodeURIComponent(url);
		s+= '+&title='+encodeURIComponent(formName.hiddenTitle.value);
		//alert(s);
	}
	
	getData(root+ax, s);	
}

function reloadImage(root,el)
{
	var imgSrc;
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	var is_ie6 = b_version.search(/msie 6/i);
//	alert("browser = " + browser + ";  " + "b_version = " + b_version + ";  " + "version = " + version + ";");
	if (browser=="Microsoft Internet Explorer" && is_ie6 > -1)
	{
		if(el=="rImage"){			
			imgSrc = '/php/turing/button.php';
		}else if(el=="ef_rImage"){
			imgSrc = '/php/turing/button.php?formType=ef';
		}
		var imgDivObj = document.getElementById('verifyImgDiv');
		var imgInnerHTML = "<img id ='rImage' src='" + imgSrc + "'  alt='verification image, type it in the box' align='absbottom' />";
		imgDivObj.innerHTML = imgInnerHTML;
	}
	else
	{
		if(el=="rImage"){
			document.getElementById(el).src = '/php/turing/button.php?rand=' + Math.round((Math.random()*9)+1);
		}else if(el=="ef_rImage"){
			document.getElementById(el).src = '/php/turing/button.php?rand=' + Math.round((Math.random()*9)+1) +'&formType=ef';
		}
	}
	return false;
}

//Search functions

function Gsitesearch(curobj){
	curobj.q.value="site:"+"http://www.mawtani.com/"+" "+curobj.searchBox.value;
}
function clearForm(curobj){

	if(curobj.value == 'search'){
		curobj.value = '';
	}
}



// getting date
var currentDate = new Date ();
function takeYear(theDate) {
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}
var currMinutes = currentDate.getMinutes();	
	if ( currMinutes < 10 ) { currMinutes = '0' + currMinutes; }
var currHour = currentDate.getHours();
	if ( currHour < 10 ) { currHour = '0' + currHour;  }
var currDay = currentDate.getDate();
var currMonth = (currentDate.getMonth() + 1);
var currYear = takeYear ( currentDate );

var currOffset = 'GMT'; //start of currOffset.
var plusminus = '';
var offset = currentDate.getTimezoneOffset(); //returns in Minutes
	if ( offset > 0 ) { plusminus = '-'; } else { plusminus = '+'; }
	offset = Math.abs(offset / 60); //finds number of hours, absolute valued
	if ( offset != 0 ) { currOffset = currOffset + plusminus + offset; }
var dateUpdated = currYear + '/' + currMonth + '/' + currDay + ' ' + currHour + ':' + currMinutes + ' ' + currOffset;
