﻿
///
///Hide || display related Items

var cookievalue = "UserID=0123#@%$UserName=Mohammad@hotmail.com#@%$FirstName=Mohammad#@%$LastName=Anabtawi"
//createCookie('HHWCookie',cookievalue,'1')

function RelatedITM()
{
try
{
var RelatedLinksinnerHTML=document.getElementById('links').innerHTML;

var TRsplitter=RelatedLinksinnerHTML.toLowerCase().split('<tr>');

var Secondpart=TRsplitter[1];
var TbodySplitter=Secondpart.split('</tbody>');
var FirstPart=TbodySplitter[0];
if(FirstPart=='</tr>')
{
document.getElementById('related').style.display='none';

}
}
catch(e)
{
 
}
}
// this following function for redirection betwwen publishing system and online site for blog and the main site


		  function home()
		  {

		  var url=window.location.href;
		  var firstsplit=url.split("http://");
		  var secondsplit=firstsplit[1].split("/");
		  var domain=secondsplit[0];
		  var blog=document.getElementById('blgsite').innerHTML;
		  var publishblog=document.getElementById('hhwblog').innerHTML;
		  var site=document.getElementById('publishsite').innerHTML;
		  var publishsite=document.getElementById('englishpblish').innerHTML;
		  var hhwapublish=document.getElementById('hhwarsite').innerHTML;




		  if(domain==blog)
		  {
		  window.location.href="http://"+publishsite;
		  }
		  else if(domain==publishblog)
		  {
		  window.location.href="http://"+hhwapublish;
		  }
		  else if(domain==hhwapublish)
		  {

		  window.location.href="http://"+hhwapublish;
		  }
		  else
		  {

		  window.location.href="http://"+domain;
		  }
		  }
	 
		  function sitemap()
		  {

		  var url=window.location.href;
		  var firstsplit=url.split("http://");
		  var secondsplit=firstsplit[1].split("/");
		  var domain=secondsplit[0];
		  var blog=document.getElementById('blgsite').innerHTML;
		  var publishblog=document.getElementById('hhwblog').innerHTML;
		  var site=document.getElementById('publishsite').innerHTML;
		  var publishsite=document.getElementById('englishpblish').innerHTML;
		  var hhwapublish=document.getElementById('hhwarsite').innerHTML;

		  if(domain==blog)
		  {
		  window.location.href="http://"+publishsite+"/pages/sitemap.aspx";
		  }
		  else if(domain==publishblog)
		  {
		  window.location.href="http://"+hhwapublish+"/pages/sitemap.aspx";
		  }
		  else if(domain==hhwapublish)
		  {

		  window.location.href="http://"+hhwapublish+"/pages/sitemap.aspx";
		  }
		  else
		  {

		  window.location.href="http://"+domain+"/pages/sitemap.aspx";
		  }
		  }
	
		  function languageshifter()
		  {
		  
		  var domain=window.location.host;
		  var hhwpublish=document.getElementById("publishsite").innerHTML;
		  var hhw=document.getElementById("hhwarsite").innerHTML;
		  var hhwpublishblog=document.getElementById("blgsite").innerHTML;
		  var hhwblog=document.getElementById("hhwbloog").innerHTML;
		  var ar_blog=document.getElementById('ar_blgsite').innerHTML;
		  var ar_publishblog=document.getElementById('ar_hhwblog').innerHTML;
		  var ar_publishsite=document.getElementById('ar_englishpblish').innerHTML;
		  var ar_hhwapublish=document.getElementById('ar_hhwarsite').innerHTML;
		  var siteee;
		  
		  if(domain==hhwpublish)
		  {
		  siteee=ar_publishsite;
		 
		  }
		  if(domain==hhw)
		  {
		  siteee=ar_hhwapublish;
		
		  }
		  if(domain==hhwpublishblog)
		  {
		  siteee=ar_blog;
		 
		  }
		  if(domain==hhwblog)
		  {
		  siteee=ar_publishblog;
		 
		  }
  window.location.href='http://'+siteee;
		  }

	



		function footerrediriction(pagename)
		{
		
		var domain=window.location.host;
		var hhwpublish=document.getElementById("publishsite").innerHTML;
		var hhw=document.getElementById("hhwarsite").innerHTML;
		var hhwpublishblog=document.getElementById("blgsite").innerHTML;
		var hhwblog=document.getElementById("hhwbloog").innerHTML;
		var direction;
		if(domain==hhwpublish)
		{
		direction='http://'+hhwpublish+"/pages/"+pagename;
		}
		else if(domain==hhw)
		{
		direction='http://'+hhw+"/pages/"+pagename;
		}
		else if(domain==hhwpublishblog)
		{
		direction='http://'+hhwpublish+"/pages/"+pagename;
		}
		else
		{
		direction='http://'+hhw+"/pages/"+pagename;
		}
		window.location.href=direction;
		}
		
		function footerredirictionContac(pagename)
		{
		
		var domain=window.location.host;
		var hhwpublish=document.getElementById("publishsite").innerHTML;
		var hhw=document.getElementById("hhwarsite").innerHTML;
		var hhwpublishblog=document.getElementById("blgsite").innerHTML;
		var hhwblog=document.getElementById("hhwbloog").innerHTML;
		var direction;
		if(domain==hhwpublish)
		{
		direction='http://'+hhwpublish+"/"+pagename+"/pages/default.aspx";
		}
		else if(domain==hhw)
		{
		direction='http://'+hhw+"/"+pagename+"/pages/default.aspx";
		}
		else if(domain==hhwpublishblog)
		{
		direction='http://'+hhwpublish+"/"+pagename+"/pages/default.aspx";
		}
		else
		{
		direction='http://'+hhw+"/"+pagename+"/pages/default.aspx";
		}
		//alert(direction);
		window.location.href=direction;
		}



//Begin iH_Submit function
function iH_Submit()
{
    var txtKeyword;
    txtKeyword = document.getElementById("SearchTextField").value;
        if(txtKeyword != '')
        {
            window.location.href = "/Search/Results.aspx?k=" + txtKeyword
        }else{
            alert("Please enter one or more search words");
        }
}
//End iH_Submit function
//***********************************************************************///
//Begin iH_OSBEK function
function iH_OSBEK(event1)
{
    var kCode = String.fromCharCode(event1.keyCode);
    if(kCode == "\n" || kCode == "\r")
    {   
        iH_Submit();
    }
}
//End iH_OSBEK function
//***********************************************************************///
//Begin showAndHideSub function
function showAndHideSub(id,sub)
{
    //alert(id)
    //alert(document.getElementById(id))
    
	var imageId = "img" + id;
	var tdId= "main" + id;
	var ShowDot="ShwoDoted"+id;

	if(document.getElementById(tdId).style.display == 'none')
	{
	    document.getElementById(tdId).style.display ='';
	    if (sub == 0)
	    {
		    document.getElementById(imageId).src = '/_layouts/1033/IMAGES/iHHHW/minus.jpg';
		}
		else
		{
		    document.getElementById(imageId).src = '/_layouts/1033/IMAGES/iHHHW/minus1.jpg';
		}
	}else{
	    document.getElementById(tdId).style.display ='none';
	    if (sub == 0)
	    {
		    document.getElementById(imageId).src = '/_layouts/1033/IMAGES/iHHHW/blusjpg.jpg';
		}
		else
		{
		    document.getElementById(imageId).src = '/_layouts/1033/IMAGES/iHHHW/blusjpg1.jpg';
		}
		
	}
}
//End showAndHideSub function
//***********************************************************************///
//Begin ShowCursor function
function ShowCursor(id)
{
	var str;
	str=id
	str.substring(0,4)
	var imgId;
	imgId=str.substring(4)
	if (str.substring(0,4)=='plus')
	{
		document.getElementById(str).style.cursor='hand';
	}else{
		document.getElementById(str).style.cursor='';
		document.getElementById(str).style.display='block';
		document.getElementById(imgId).src="/_layouts/1025/IMAGES/iHCom/SMMinusIcon.gif";
	}
}
//End ShowCursor function
//***********************************************************************///
//Begin Mouse Over Article that change article display and Image source
//  imgSrc : Image Source , ObjID :'Idintity' (td ID) , ImgId : which image will be change , Area : Action Type (Main , Events or Conferences)
function DisplayMainArticle(imgSrc , ObjID , ImgId , Area)
{
 	var imageMainArticle = document.getElementById(ImgId)
 	if(imageMainArticle)
 	{
 		if(imgSrc)
 		{
 			imageMainArticle.style.display = "";
 	   		imageMainArticle.src = imgSrc;			                 		
 		}
 		else
 		{
 			imageMainArticle.style.display = "none";
 		}
 	}
 	switch(Area)	                 	
 	{
 		case "MainArea":
 		{
 			var rowCount = document.getElementById("ArticleRowCount").value
 			for(i=1;i <= rowCount ;i++)
             	{
             		if(document.getElementById('TitleDesc'+i) && document.getElementById('TitleOnly'+i))
             		{
                 		if(i == ObjID)
                 		{
                 			document.getElementById('TitleDesc'+i).style.display = "";
                 			document.getElementById('TitleOnly'+i).style.display = "none";

                 		}
                 		else
                 		{
                 			document.getElementById('TitleDesc'+i).style.display = "none";
                 			document.getElementById('TitleOnly'+i).style.display = "";
                 		}
                 	}
             	}
 			break;		                 		
 		}
 		case "EventArea":
 		{
 			var rowCount = document.getElementById("EventsRowCount").value
 			for(i=1;i <= rowCount ;i++)
             	{
             		if(document.getElementById('tdEvents'+i))
             		{
                 		if(i == ObjID)
                 		{
                 			document.getElementById('tdEvents'+i).className = "brownTblBG";

                 		}
                 		else
                 		{
                 			document.getElementById('tdEvents'+i).className= "txt04";
                 		}
                 	}
             	}
 			break;
 		}
 		case "ConferencesArea":
 		{
 			var rowCount = document.getElementById("ConferencesRowCount").value
 			for(i=1;i <= rowCount ;i++)
             	{
             		if(document.getElementById('tdConferences'+i))
             		{
                 		if(i == ObjID)
                 		{
                 			document.getElementById('tdConferences'+i).className = "brownTblBG";

                 		}
                 		else
                 		{
                 			document.getElementById('tdConferences'+i).className= "txt09";
                 		}
                 	}
             	}
 			break;
 		}
 	}
}
//***********************************************************************///
//Begin PrintIt function
function PrintIt()
{
eraseCookie("StrURL");
eraseCookie("StrVal");
eraseCookie("StrTitle");
 
    var strstr
    var strtitle
    var strURL
    
    strURL = escape(window.location.href)
    createCookie('StrURL',strURL,'1')
    
    if (document.getElementById("PrintContent"))
    {
        //strstr = escape(document.getElementById("PrintContent").innerHTML.replace(/<\/?a [^>]*>/gi, "" ).replace(/<\/?input /gi, "<input disabled  ").replace(/<\/?select /gi, "<select disabled ").replace(/<\/?TBODY [^>]*>/gi, "<TBODY>" ))
        //createCookie('StrVal',strstr,'1')
    }
    
    if (document.getElementById("PrintTitle"))
    {
        strtitle = escape(document.getElementById("PrintTitle").innerHTML.replace(/<\/?a [^>]*>/gi, "" ).replace(/<\/?input /gi, "<input disabled  ").replace(/<\/?select /gi, "<select disabled ").replace(/<\/?TBODY [^>]*>/gi, "<TBODY>" ))
        createCookie('StrTitle',strtitle,'1')
    }
    
    window.location = ("/Pages/print.aspx");
    
    //window.open("/Pages/print.aspx",null,"height=500,width=500,status=no,toolbar=no,menubar=no,location=no,scrollbars=1");
}
//End PrintIt function
//***********************************************************************///
// Begin Newsletter Functions
//***********************************************************************///
// function isValidEmail implemented using regular expressions
function isValidEmail (strEmail)
{
	var emailRegExp = /^.+\@.+\..+$/  ;
	strEmail = Trim(strEmail) ;
	return emailRegExp.test(strEmail) ;
}
////////////////////////////////////////////////////////
// trim is similar to the Trim fucntion in VBScript   //
//   it uses ltrim(left trim), to eliminate the left  //
//   side spaces, and rtrim(right trim),to eliminate  //
//   the right side spaces.                           //
// Parameters:                                        //
//	IN - strParam : the id of the text input          //                        
////////////////////////////////////////////////////////
function Trim(strParam)
{
	strParam = LTrim(strParam) ;
	strParam = RTrim(strParam) ;
	return strParam ;
}
// Eliminate all Left Spaces	////////////
function LTrim(strParam)
{
	var c;
	for(var i = 0 ; i < strParam.length ; i++)
	{
		c = strParam.charAt(i) ;
		if( c != " ")
			break ;
	}
	strParam = strParam.substring(i,strParam.length)	 ;
	return strParam ;
}
// Eliminate all Right Spaces	/////////////
function RTrim(strParam)
{	
	var c ;
	for(var i = strParam.length-1 ; i>0 ; i--)
	{
		c = strParam.charAt(i) ;
		if( c != " " )
			break ;
	}
	if(i != strParam.length-1)
		strParam = strParam.substring(0,i+1) ;
	
	return strParam ;
}
//Begin SubscribeUser function
function SubscribeUser()
{
	var strUserEmail = Trim(document.getElementById("userEmailAddress").value) ;
	if (strUserEmail == "")
	{
			alert("Please insert your Email ") ;
			document.getElementById("userEmailAddress").focus();
			return false ;
	}
	else 
	{
	 if( !(isValidEmail(strUserEmail)) )
	  {	
		alert("Please insert your email as the following form :"+ "\n name@domain.com");
		document.getElementById("userEmailAddress").focus();		
		return false ;
	  }
	   // if every thing goes well 
	   SaveUser(strUserEmail);
	}
}
//End SubscribeUser function
//***********************************************************************///
//Begin SaveUser function
function SaveUser(strUserEmail)
{
	var lng    = "1"; // to indicate english site language
	var result = "-1"; // to indicate error as default	
	var lblResult = document.getElementById("subscribtionResult") ;
	// apply an HTTPRequest
	// send an HTTPRequest to save the data on an ASPX page
	var objHTTPRequest;
	try
	{
		// IE
		objHTTPRequest = new ActiveXObject("MSXML2.XMLHTTP") ;
	}
	catch( e )
	{
		//firefox
		objHTTPRequest=new XMLHttpRequest();
	}
	
	var strURL = "/iHServices/site/Newsletter/pages/Subscribe.aspx?lng=" + lng + "&email=" + strUserEmail ;

	try
	{
	
		objHTTPRequest.open("POST",strURL,false) ; // false for asyncronous call
												   // which means wait tell the page
											       // is fully executed, and read the returned value
		// send the request
		objHTTPRequest.send("");
		// check the result
		switch(objHTTPRequest.responseText)
		{
			case "0" : // email saved correctly
				alert("Thank you for subscribing Newsletter");
				//document.getElementById("userEmailAddress").disabled = true ;
				document.getElementById('divNewsLetterArea').style.display = "none";
				var OverFlowMainBlock = document.getElementById('OverFlowMainBlock');
                if(OverFlowMainBlock){
                    OverFlowMainBlock.style.display = "none";
                    document.body.style.overflow = "";
                }

				break ;
			case "1" : // already used email
				alert("This email is already used");
				document.getElementById("userEmailAddress").focus();
				break ;
			default : // Error
				//lblResult.innerHTML = "Sorry, There was an error during saving process";
				alert("Sorry, There was an error during saving process");
				break ;
		}	
	}
	catch(e)
	{
		alert(e.description);
		return false ;
	}
	
	objHTTPRequest =  null ;
}
//End SaveUser function
//***********************************************************************///
//Begin OnTextBlur function
function OnTextBlur()
{
    var txt = Trim(document.getElementById("userEmailAddress").value);
    if(txt == "")
    {
        document.getElementById("userEmailAddress").value="Type your email here";
    }
}
// End OnTextBlur function
//***********************************************************************///
//Begin OnTextFocus function
function OnTextFocus()
{
    var txt=document.getElementById("userEmailAddress").value;
    if(txt=="Type your email here")
    {
        document.getElementById("userEmailAddress").value = "";
    }
   
}
//End OnTextFocus function
//***********************************************************************///
//Begin SetGoButtonFocus function
function SetGoButtonFocus()
{
    document.getElementById("btnGo").focus();
}
// End SetGoButtonFocus function
//***********************************************************************///
//Begin ShowNewsletter function
function ShowNewsletter()
{
    //var gimagespath = document.getElementById("g_images_path").value
    var OverFlowMainBlock = document.getElementById('OverFlowMainBlock');
    if(document.getElementById('divNewsLetterArea').style.display == 'none' )
    {
        document.getElementById('divNewsLetterArea').style.display = "";
        if(OverFlowMainBlock){OverFlowMainBlock.style.display = "";
        document.body.style.overflow = "hidden";
        OverFlowMainBlock.style.height = document.body.clientHeight; 
        }
    }
    else{
        document.getElementById('divNewsLetterArea').style.display = "none";
        if(OverFlowMainBlock){
            OverFlowMainBlock.style.display = "none";
            document.body.style.overflow = "";
        }
    }
}
//End ShowNewsletter function
//***********************************************************************///
// End Newsletter Functions
//***********************************************************************///
function getNoOfRow(total)
{
	var NewStr = "";
	
	createCookie('PauseValue','0','1')
	
	NewStr = "<table width='300' border='0' align='right' cellpadding='0' cellspacing='0' class='paging'>"
	NewStr = NewStr + "<tr><td width='150'>&#160;</td>"
	for(var index=1;index<= total; index++)
	{
	    
	    NewStr = NewStr +"<td id='tdimg" + index + "' width='18' valign='top'></td>";   
	}
	
	NewStr = NewStr +"<td width='60'>&#160;</td></tr>"
	
	NewStr = NewStr + "<tr><td id='PauseAndPlayTd'><a href='#' onclick='PauseAndPlay(1);'><img src='/_layouts/1033/IMAGES/iHHHW/pause.jpg' width='69' height='21' hspace='15' border='0' align='right' /></a></td>"
	
	for(var index=1;index<= total; index++)
	{
	    
	    NewStr = NewStr +"<td id='td" + index + "'><a onclick='ShowHide("+ index +","+ total +")' style='cursor:pointer'>"+ index +"</a></td>";   
	}
    
    NewStr = NewStr + "<td><a style=cursor:pointer onclick='morenews()'>More</a></td></tr></table>"
    
    //prompt('',NewStr)
    
    document.getElementById("paging").innerHTML = NewStr
    
    ShowHide (1,total);
    
}
function morenews()
{
          var currhost=window.location.host;
		  var blog=document.getElementById('blgsite').innerHTML;
		  var publishblog=document.getElementById('hhwblog').innerHTML;
		  var site=document.getElementById('publishsite').innerHTML;
		  var publishsite=document.getElementById('englishpblish').innerHTML;
		  var hhwapublish=document.getElementById('hhwarsite').innerHTML;
		  var newspath=document.getElementById('morenews').innerHTML;
		  var directpath;
        if(currhost==blog)
        {
      directpath='http://'+site+newspath;
        }
        else if(currhost==publishblog)
        {
        directpath='http://'+hhwapublish+newspath;
        }
        else if(currhost==site)
        {
        directpath='http://'+site+newspath;
        }
        else
        {
        directpath='http://'+hhwapublish+newspath;
        }
        window.location.href=directpath;
        
}

function ShowHide(target,total)
{
    
    var tdtarget
    var CurrentTarget
	var TotalNumbr
	var DivId
	var NextTarget
	var PauseValue
	
	if (target == undefined)
	{
	    if (readCookie('PauseValue') == 0)
	    {
		target = parseInt (readCookie('CurrentIndex')) + 1
		}
		else
		{
		target = parseInt (readCookie('CurrentIndex'))
		}
		total = parseInt (readCookie('CurrentTotal'))
		if (target > total )
		{
			target = 1
		}
	}
	
	
	createCookie('CurrentIndex',target,'1')
	createCookie('CurrentTotal',total,'1')
	
    CurrentTarget = readCookie('CurrentIndex')
    TotalNumbr = readCookie('CurrentTotal')
    PauseValue = readCookie('PauseValue')
    
    tdtarget = "td" + target
   
        for(var index=1;index<= total; index++)
	    {
	        //alert("target : " + target)
            //alert("IndexID : " + index)
            var IndexID = "TR" + index
	        if (index != target)
	        {
	            if (document.getElementById(IndexID))
	            {
	            document.getElementById(IndexID).style.display = "none";
	            }
    	        
	            if (document.getElementById(tdtarget))
	            {
	                document.getElementById("td" + index).innerHTML = "<td id='td" + index + "'><a onclick='ShowHide("+ index +","+ total +")' style='cursor:pointer'>"+ index +"</a></td>";
	                document.getElementById("tdimg" + index).innerHTML = ""
	            }
    	        
	        }
	        else
	        {
	            if (document.getElementById(IndexID))
	            {
	                document.getElementById(IndexID).style.display = "";
	            }
    	        
	            if (document.getElementById("td" + index))
	            {
	                document.getElementById("td" + index).innerHTML = "<td id='td" + index + "'><span class='paging'>"+ index +"</span></td>";
	                document.getElementById("tdimg" + index).innerHTML = "<img src='/_layouts/1033/IMAGES/iHHHW/downArrow.jpg' width='13' height='8' align='top'/>"
	                
	            }
    	        
	        }
    	    
	    }
    	
     if (PauseValue == 0)
	{	
	    setTimeout('ShowHide();', 20000);
	}
	
}

//***********************************************************************///
// Pause and Play Functions
//***********************************************************************///

function PauseAndPlay (PauseValue)
{
 var PauseValue

createCookie('PauseValue',PauseValue,'1')

PauseValue = readCookie('PauseValue')

    if (PauseValue == 0 )
    {
        document.getElementById("PauseAndPlayTd").innerHTML = "<a href='#' onclick='PauseAndPlay(1);'><img src='/_layouts/1033/IMAGES/iHHHW/pause.jpg' width='69' height='21' hspace='15' border='0' align='right' /></a>"
        setTimeout('ShowHide();', 20000);
    }
    else
    {
        document.getElementById("PauseAndPlayTd").innerHTML = "<a href='#' onclick='PauseAndPlay(0);'><img src='/_layouts/1033/IMAGES/iHHHW/play.jpg' width='69' height='21' hspace='15' border='0' align='right' /></a>"
    }

}

//***********************************************************************///
// End Of Pause and Play Functions
//***********************************************************************///

//***********************************************************************///
// Coockies Functions
//***********************************************************************///

function createCookie(name,value,days) {

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";

}

function readCookie(name) {


	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	//alert(ca.length);
	//var xxx;
	for(var i=0;i < ca.length;i++) {

		var c = ca[i];
		
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0)
		{
		 //alert("access hhwcookie")
		 //alert(c.substring(nameEQ.length,c.length));
		 //xxx=c.substring(nameEQ.length,c.length);
		
		return c.substring(nameEQ.length,c.length);
		}
	}
	
	//return xxx;
	return null;
}

function eraseCookie(name) {


	createCookie(name,"",-1);
}

//***********************************************************************///
// End Of Coockies Functions
//***********************************************************************///

//-----------------------------------------------------------------------------changeFontSize
function changeFontSize(fontSize) {
	
			//debugger;
			var cssFileName;

			switch (fontSize) {
			case 1: cssFileName = 'style1.css'; break;
			case 2: cssFileName = 'styles.css'; break;
			case 3: cssFileName = 'style2.css'; break;
			}
			href = '/_layouts/1033/STYLES/iHHHW/' + cssFileName ;
			if (document.getElementById("ctl00_ctl00_bodyCSS"))
			document.getElementById("ctl00_ctl00_bodyCSS").href = href;

			}

//-----------------------------------------------------------------------------getActiveStyleSheet

function getActiveStyleSheet() {

    href = document.getElementById("ctl00_ctl00_bodyCSS").href;
    x = href.lastIndexOf('/') + 1;
    y = href.lastIndexOf('.')
    cssFileName = href.substring(x, y);
    return cssFileName;
}

//-----------------------------------------------------------------------------onLoad

window.onload = function(e) {
    var cookie = readCookie("style");
    var title = cookie ? cookie : getActiveStyleSheet();
    if (cookie != null) { setActiveStyleSheet(title); }
    //rerender(4);
}

function setActiveStyleSheet(cssFileName) {
    href = '/_layouts/1033/STYLES/iHHHW/' + cssFileName + '.css';
    document.getElementById("ctl00_ctl00_bodyCSS").href = href;
    return null;
}

//-----------------------------------------------------------------------------onunLoad

window.onunload = function(e) {
    var title = getActiveStyleSheet();
    createCookie("style", title, 365);
}

//***********************************************************************///
// change language Functions
//***********************************************************************///

function changelng(Domain)
{
    var Newpath
    var FullPath = window.location.href
    var CurrentDomain = window.location.host
    
    Newpath = FullPath.replace(CurrentDomain, Domain);
    location.replace(Newpath);
}

function OpenMainMenu(ID)
{

//debugger;
if(document.getElementById(ID))
 {   
    if(document.getElementById(ID).style.display == 'none')
	{
	    document.getElementById(ID).style.display ='';
	}else{
	    document.getElementById(ID).style.display ='none';
	}
  }
}

function ShowDivSubMenu(Id)
	{
	    var DivId = "Div" + Id
	    //var TdId = "TD" + Id
	    
	    if (document.getElementById(DivId))
	    {
	        document.getElementById(DivId).style.display = "";
	        //document.getElementById(TdId).className = "MenuBG";
	        
	    }    
		
	}
	
function HideDivSubMenu(Id)	
    {
        var DivId = "Div" + Id
        
        if (document.getElementById(DivId))
        {
	        document.getElementById(DivId).style.display = "none";
	    }    
    }

function ChangeTdStyle(Id,StyleName)
    {
        var TdId = "TDNew" + Id
        var ImgId = "Img" + Id
        
        if (document.getElementById(TdId))
        {
	        document.getElementById(TdId).className = StyleName;
	    }
	    
	    if (document.getElementById(ImgId))
        {
	        document.getElementById(ImgId).src = "/_layouts/1033/IMAGES/iHHHW/level2Arw.jpg";
	    }
	    
    }
    
function EmptyTdStyle(Id,StyleName)
    {
        var TdId = "TDNew" + Id
        var ImgId = "Img" + Id
        
        if (document.getElementById(TdId))
        {
	        document.getElementById(TdId).className = StyleName;
	    }
	    
	    
	    if (document.getElementById(ImgId))
        {
	        document.getElementById(ImgId).src = "/_layouts/1033/IMAGES/iHHHW/menuParent.jpg";
	    }
	    
    }
    
function ChangeTdStyleBySub(Id,StyleName)
    {
        var TdId = "TDNew" + Id
        var ImgId = "Img" + Id
        
        if (document.getElementById(TdId))
        {
	        document.getElementById(TdId).className = StyleName;
	    }
    }

/*
if (readCookie('HHWCookie') != '')
            {
                UserName = cookievalue.split(UserName)
                UserName = UserName[1].split("#@%$")
                UserName = UserName[0].replace("=", "")
                alert(UserName)
            }/*/
function CheckHeaderPathName()
{
    var HomePath = "/lists/posts/home.aspx"
    var PagePath = window.location.pathname
    var UserName = "FirstName"
    var UserLastName="LastName"
    var EmailAddress=""
    var EmailAddressName="";
    if (document.getElementById('HomeHeader'))
    {

     
        if(HomePath == PagePath)
        {
       
            document.getElementById('DetailedHeader').style.display = "none"
            document.getElementById('HomeHeader').style.display = ""
        
           
        
            if (readCookie('HHWCookie') != '')
            {
           
            
                EmailAddress=readCookie('HHWCookie').split("#@%$");
                EmailAddressName=EmailAddress[2].split("=");
                var _unescapeEmailAddressName=unescape(EmailAddressName[1]);
                
                
                UserName = readCookie('HHWCookie').split(UserName)
                UserName = UserName[1].split("#@%$")
                
                UserLastName= UserName[1];          
                UserLastName=UserLastName.replace("LastName=","");
                UserName = UserName[0].replace("=", "")
                document.getElementById('userloginHome').innerHTML = "Welcome , " + UserName+" "+UserLastName + " | <a  href='/Pages/ViewProfile.aspx?UserName="+_unescapeEmailAddressName+"'>View Profile</a>  "+" | <a  href='/_Layouts/Signout.aspx'>Sign Out</a>";           
                
            }
 
            
        }
        else
        {
    
            document.getElementById('HomeHeader').style.display = "none"
            document.getElementById('DetailedHeader').style.display = ""
     
             if (readCookie('HHWCookie') != '')
            {
              
                    
                    EmailAddress=readCookie('HHWCookie').split("#@%$");
                    EmailAddressName=EmailAddress[2].split("=");
                    var _unescapeEmailAddressName=unescape(EmailAddressName[1]);
                    

                    UserName = readCookie('HHWCookie').split(UserName);
                    UserName = UserName[1].split("#@%$");
                    
                    UserLastName= UserName[1]; 
                    UserLastName=UserLastName.replace("LastName=","");
                    
                    UserName = UserName[0].replace("=", "")
                    document.getElementById('userloginDetailed').innerHTML = "Welcome , " + UserName+" "+UserLastName + " | <a href='/Pages/ViewProfile.aspx?UserName="+_unescapeEmailAddressName+"'>View Profile</a>  "+" | <a  href='/_Layouts/Signout.aspx'>Sign Out</a>";           

   
       
            }
            
        }
        
    }
}
////signout out page and erase the cookeis 
//createdby Anas Nazzal 
  function SignOut(){
    eraseCookie("HHWCookie");
    window.close();
  }


function ImgPicker()
{
var Path = document.getElementById('img').innerHTML;

var ImagePath=Path.split("src=\"");

var ImageURL=ImagePath[1].split("\" style");

if (document.getElementById('IAMGE'))
    {
    document.getElementById('IAMGE').src=ImageURL[0];
    }
}
function SimpleSearch(target)
{

    var Key
    var SearchPage
    Key = document.getElementById('textfield').value
    SearchPage ="http://"+window.location.host+target+Key+"&s=EnArticles"
    var domainname=window.location.host+target;
    var domain = domainname.split("/");
    var realdomainone=domain[1];
    var realdomaintwo=domain[2];
    var realdomain=domain[0];
    var blog=document.getElementById('blgsite').innerHTML;
    var hhwpub=document.getElementById('hhwarsite').innerHTML;
    var hhwblog=document.getElementById('hhwblog').innerHTML;
    var hhw=document.getElementById('publishsite').innerHTML;
  

    if(realdomain==hhwblog)
    {
   
    realdomain=hhwpub+"/"+realdomainone+"/"+realdomaintwo;
    }
   if(realdomain==blog)
    {
    realdomain=hhw+"/"+realdomainone+"/"+realdomaintwo;
    }
    if(realdomain==hhw)
    {
   
    realdomain=hhw+"/"+realdomainone+"/"+realdomaintwo;
  
    }
    if(realdomain==hhwpub)
    {
   
    realdomain=hhwpub+"/"+realdomainone+"/"+realdomaintwo;
    };
    SearchPage ="http://"+realdomain+Key+"&s=EnArticles"
    window.location.href = SearchPage;
    
    
}

function getCookie(c_name)
{ 
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return ""
}

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.toUTCString());
}


function checkCookie(cname,cnameid,type)
{
name=getCookie(cname);
if (name!=null && name!="")
  {
  if(type=='select')  
   document.getElementsByName(cnameid)[0].selectedIndex=name;
  else
    document.getElementsByName(cnameid)[0].value=name;

  }
 }
 
 
function RemoveQS()
{
var urlparts= self.location.href.split('?'); 
if (urlparts.length>=2) 
{
    var prefix= encodeURIComponent('start1')+ '='; 
    var pars= urlparts[1].split(/[&;]/g); 
    for (var i= pars.length; i-->0;)              
        if (pars[i].lastIndexOf(prefix, 0)!==-1)  
            pars.splice(i, 1);    
    
    var newURL=urlparts[0]+'?'+pars.join('&'); 
    //window.location.href = "/sites/blogs/Search/advanced.aspx?PageView=Shared";
   //alert(newURL);
   //alert(window.location.href);   
 }
  //
  // window.location.href ='http://ihhhodev-vpc11:32948/sites/blogs/Search/advanced.aspx';
  // top.location.href='http://ihhhodev-vpc11:32948/sites/blogs/Search/advanced.aspx';
  // self.location.href='http://ihhhodev-vpc11:32948/sites/blogs/Search/advanced.aspx';
   
}

//****************************************************//
//     Function For Date Formating In Template        //
//****************************************************//

	function DateFormat(x){
			
			
			var j=url.substr(0,10);
		    
		    var yer=j.substr(0,4);
		 
		   	var mont1=j.charAt(5)
		   	var mont2=j.charAt(6)
		   	var mont=mont1+mont2;
		    
		    var day=j.substr(8,10);
		   
		    
		    switch (mont) {
		case "01" :
		mont="January"
			break;
		case "02" :
		mont="February"

			break;
		case "03" :
		mont="March"

			break;
		case "04" :
		mont="April"
			
			break;
		case "05" :
		mont="May"
			
			break;
		case "06" :
		mont="June"
		
			break;
		case "07" :
		mont="July"
			break;
			case "08" :
			mont="August"
			break;
		case "09" :
		mont="September"

			break;
		case "10" :
		mont="October"

			break;
		case "11" :
		mont="November"
						break;
			case "12" :
			mont="December"
			
			break;
}

		   
		   var firstindX= day.charAt(1);
		   
			
			
					    switch (firstindX) {
		case "0" :
		firstindX="th";
			break;
		case "1" :
		firstindX="st"
			break;
		case "2" :
		firstindX="nd"

			break;
		case "3" :
		firstindX="rd"

			break;
		case "4" :
		firstindX="th"
			
			break;
		case "5" :
		firstindX="th"
			
			break;
		case "6" :
		firstindX="th"
		
			break;
		case "7" :
		firstindX="th"
			break;
			case "8" :
			mont="th"
			break;
		case "9" :
		firstindX="th"

			break;
		
}
			
			
			
			
			
            document.write(day+firstindX+" "+mont+" ");
            document.write(yer);			
            
 
}


//****************************************************//
//     Function Add Id In Blog-Site         //
//****************************************************//

function AddId(){

var URL = unescape(location.href);
var temp = new Array();
temp = URL.split("=");
var templnth=temp.length;
if(templnth<4)
{
var e=URL.split("=");
var id=e[2];

window.location.href =URL+"&id="+id;
}

}
 function shifter(url){
      var URL = unescape(location.href);
      var temp = new Array();
      temp = URL.split("/");
      var currenturl=temp[2];
      var blogingsite=document.getElementById('blgsite').innerHTML;
      var publishingsite=document.getElementById('site').innerHTML;
      var hhwblog=document.getElementById('hhwarsite').innerHTML;
      var realurl;
      if(currenturl==blogingsite)
      {
      realurl=publishingsite;
      }
      else{
      realurl=hhwblog;
      };
      
      var GoTo = "http://" + realurl + url ;
      document.location.href = GoTo;

      }
      function hide()
      {
      document.getElementById('transdiv').style.display='none';
      }
      function CopyToClipboard()
      {
       CopiedTxt = document.selection.createRange();
       CopiedTxt.execCommand("Copy");
}
