    function csId(csId){ return document.getElementById(csId); }
	function csSub(csVal){
	try{ if(csVal) csId('hpMoreMenu'+csVal).style.display = 'block';	}catch(err){}
	}	
	function csSubOut(csVal){ try{csId(csVal).style.display = 'none'; }catch(err){}}
	function csSubTime(csVal){ try{setTimeout("csSubOut('"+csVal+"')", 4000);  }catch(err){}}
	function csSubOver(csVal){ try{csId(csVal).style.display = 'block'; }catch(err){}}	
	function searchnow(element){
		var str = csId(element).value;			
		if((str!="") && (str!="Search")){
			/*var user = csId('usrSrch').value;
			if (user == '' )user = 0;*/			
			document.location.href="http://search.ibibo.com/isearch/result/provider/searchibibo_all/1/?q="+URLEncode(str);			
		}else{
			csId(element).focus();
		}
	}	
	function URLEncode (clearString){
		var output = '';
		var x = 0;
		clearString = clearString.toString();
		var regex = /(^[a-zA-Z0-9_.]*)/;
		while (x < clearString.length) {
			var match = regex.exec(clearString.substr(x));
			if (match != null && match.length > 1 && match[1] != '') {
			output += match[1];
			x += match[1].length;
			} else {
			if (clearString[x] == ' ')
			output += '+';
			else {
				var charCode = clearString.charCodeAt(x);
				var hexVal = charCode.toString(16);
				output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
			}
			x++;
			}
		}
		return output;
	}

	/* FOR SHOWING MAIL COUNT */
	var cslCookies = document.cookie.split( ';' );	
	var allC ="";
	for ( i = 0; i < cslCookies.length; i++ ){			
		cslTempCookie = cslCookies[i].split( '=' );
		cslCookieN = cslTempCookie[0].replace(/^\s+|\s+$/g, '');	
		allC = allC + ","+cslCookieN;
	}
	/*if( (allC.indexOf('smimid')!=-1) && (allC.indexOf('e,')!=-1) && (allC.indexOf('u,')!=-1)){*/
		var EUnReadCount=0;
		function mycallH(ret){			
			var el = csId('unreadCount');
			if((el!=null)&& (el!='undefined')){
				if(parseInt(ret.unread)>=0){
					if(parseInt(ret.unread)>999){ ret.unread="999+"; }
					var ii =(""+ ret.unread).length;
					if(ii>3){ ii=3; }			
					try{
						if(parseInt(ret.unread)!=0){			
							csId('unreadMain').style.display =  "block";
							csId('unreadCount').innerHTML="<span style='cursor:pointer' onclick=\'javascript:location.href=\"http://mail.ibibo.com/cgi-bin/login?fun=passport&V=1030\";\'>"+ret.unread+"</span>"; 			
						}
					}catch(e){}		
					EUnReadCount = ret.unread;
					try{ csId('EUnReadCount').innerHTML=EUnReadCount; }catch(e){}		
					try{
						if(parseInt(EUnReadCount)!=0){        	
							csId('emailCount').innerHTML = EUnReadCount;		
						/*csId('unreadEmailCnt').style.display = "block";*/		
						} else {
							csId('emailCount').innerHTML = '0';
						}
					}catch(e){}		
				}
			}	
		}
 
		var csc_count = 0;
		function csUser( csCookieN ){
			if(document.getElementById('csUsername')==null){
				csc_count = csc_count+1;
				if(csc_count<=3){
					setTimeout("csUser('fn')",50);
					return;
				}
			}
			var csCookies = document.cookie.split( ';' );	
			for ( i = 0; i < csCookies.length; i++ ){			
				csTempCookie = csCookies[i].split( '=' );
				csCookieN = csTempCookie[0].replace(/^\s+|\s+$/g, '');	
				if (csCookieN == 'fn'){
					csCookieNVal = unescape( csTempCookie[1].replace(/^\s+|\s+$/g, '') );
					csCookieNVal = csCookieNVal.replace(/\+/g, ' ');			
					if(csCookieNVal){			
						if(csCookieNVal.length > 14) csCookieNVal = csCookieNVal.substring(0,14)+'..';				
						if(document.getElementById('csUsername')!=null){
							csId('csUsername').innerHTML = csCookieNVal;
							csId('csUsername').style.display = 'inline';
						}
					}
				}	
			}			
			var csSignOut = document.getElementById('signoutlink');	
			var csSignVal = Math.floor(Math.random()*(9999-99)+99);
			if(document.getElementById('signoutlink')!=null){
			csSignOut.href = csSignOut.href.replace('cscache', csSignVal);
			}
		}	
		setTimeout("csUser('fn')",300);
	/*}*/
	/* FOR SHOWING SEPARATE HEADER FOR CLIENT REQUEST*/
	function checkClientCookie(){
		if(document.getElementById('regularHeader')==null){
			setTimeout('checkClientCookie()',50);return;
		}
		if(document.getElementById('clientHeader')==null){
			setTimeout('checkClientCookie()',50);return;
		}
			
		var csCooks = document.cookie.split( ';' );	
		var clientCookie = false;
		var sts = document.createElement('style');
		sts.setAttribute('type', 'text/css');
		var newStyle = 'body {background: url(http://static.cs.ibcdn.com/csimages/head/hd_bg.gif) repeat-x 0 -5px}\n #pageShdw {top: 26px;}'; 
		for ( i = 0; i < csCooks.length; i++ ){			
			csTempCookie = csCooks[i].split( '=' );
			csCookieN = csTempCookie[0].replace(/^\s+|\s+$/g, '');	
			if (csCookieN == 'wherefrom'){
				clientCookie = true;
				break;
			}	
		}
		if(clientCookie==true){
			newStyle = 'body {background:none }\n #pageShdw {top: 56px;}'; 	
		}else{
			newStyle = 'body {background: url(http://static.cs.ibcdn.com/csimages/head/hd_bg.gif) repeat-x 0 -5px}\n #pageShdw {top: 26px;}'; 
		}
		if(navigator.appName=='Microsoft Internet Explorer'){// IE
			sts.styleSheet.cssText = newStyle;
		} else {// w3c
			var cssText = document.createTextNode(newStyle);
			sts.appendChild(cssText);
		}
		var headRef = document.getElementsByTagName('head')[0];
		headRef.appendChild(sts); 
	
		if(clientCookie==true){
			csId('regularHeader').style.display='none';
			csId('clientHeader').style.display='block';
		}else{
			csId('clientHeader').style.display='none';
			csId('regularHeader').style.display='block';
		}
	}
	//setTimeout('checkClientCookie()',50);


function update_noti_count(){
	
	var milliseconds = new Date().getTime();

	
	var w = document.createElement('SCRIPT');	
	w.src = 'http://feeds.ibibo.com/nfo/updatetime.php?dummy='+milliseconds;
	document.getElementsByTagName('BODY')[0].appendChild(w);
	var e = csId('cs_noti_cnt');
	e.onclick = null;
	e.innerHTML = '';
}

function cs_noti_callback(data){
	if(data.count!=0)
	{
		var e = csId('cs_noti_cnt');
		e.onclick=update_noti_count;
		e.innerHTML = '<small class="red_tag"><strong>'+ data.count +'</strong></small>';
	}
	var n = data.notifications;
	var str = '<h6>Notifications</h6><ul>';
	for(var i=0;i<n.length;i++){
		var actorname = n[i].actorname.replace(" ","-");
		var x =0;
		str += '<li ' + ((n[i]['new'] == 0) ? 'onmouseout="this.className=\'\';" onmouseover="this.className=\'hover\';"' : 'onmouseout="this.className=\'latest_notification\';" onmouseover="this.className=\'latest_hover\';" class="latest_notification"') + '><span class="border"><a class="usr_img" href="http://www.ibibo.com/'+ actorname + "-" + data.notifications[i].actorUname.x + '"><img src="' + data.notifications[i].actoravatar + '" alt="" class="left" /></a><strong>' + data.notifications[i].htmlstr + '<small>' + data.notifications[i].datetime + '</small></strong></span></li>';
	}
	str += '<li style="text-align:center;"><a class="view_all" href="http://www.ibibo.com/notifications/index/myNotifications">More Notifications</a></li>';
	str += '</ul>';
	csId('cs_noti_list').innerHTML = str;
}

