function showSubMenu (id, stat, ipos) {
	var menuId;
	menuId = "subMenu" + id;
	mNav = id + "Bank";
	ipos = 0 - ipos;
	if (stat==1)
	{
	document.getElementById(menuId).style.display = "block";
	document.getElementById(mNav).style.backgroundPosition= ipos+"px -128px";
	}
	else if (stat==0)
	{
	document.getElementById(menuId).style.display = "none";
	document.getElementById(mNav).style.backgroundPosition= ipos+"px 0px";
	}
	else if (stat==3)
	{
	document.getElementById(menuId).style.display = "block";
	document.getElementById(mNav).style.backgroundPosition= ipos+"px -128px";
	}
	else if (stat==4)
	{
	document.getElementById(menuId).style.display = "none";
	document.getElementById(mNav).style.backgroundPosition= ipos+"px  0px";
	}
}
var actBanner = "banner1";

var actMnu = "home";
function showMnuTop(obj){
	
		//document.getElementById("mnu" + actMnu).style.display = "none";
		//document.getElementById(actMnu).className = "";
		document.getElementById("mnu" + obj).style.display = "block";
		document.getElementById(obj).className = "selected";
		//actMnu = obj.id;
}


function hideMnuTop(obj){	
		//document.getElementById("mnu" + actMnu).style.display = "block";
		//document.getElementById(actMnu).className = "";
		document.getElementById("mnu" + obj).style.display = "none";
		document.getElementById(obj).className = "";
		//actMnu = obj.id; 
}

function showContent(){
		if(document.getElementById('TB_window').style.visibility=='block'){
			document.getElementById('TB_window').style.visibility='none'			
		}
		else{
			document.getElementById('TB_window').style.visibility='block'
		}
	}
function showHideTask(id){	
		if(document.getElementById(id).style.display=="block")
		{
			document.getElementById(id).style.display="none";
		}
		else
		{
			document.getElementById(id).style.display="block";
		}

}
function hideTask(id){

			document.getElementById(id).style.display="none";

}
function showTask(id){	
			document.getElementById(id).style.display="block";
}
function showNav(obj,nid){
	//alert(actBanner+"#####"+obj.id)
		//document.getElementById("show" + actBanner).style.display = "none";
		document.getElementById(actBanner).className = "";
		//document.getElementById("show" + obj.id).style.display = "block";
	var baner_divs = buildcontentdivs();
	alert(baner_divs.length)
	if(obj.id == 'banner1') {
		turntopage = 1;
		//alert(setting.contentdivs)
		if(baner_divs[0])
			baner_divs[0].style.zIndex= 1;	
		if(baner_divs[1])
			baner_divs[1].style.zIndex= 0;	
		if(baner_divs[2])
			baner_divs[2].style.zIndex= 0;
	} else if(obj.id == 'banner2') {
		turntopage = 2;
		if(baner_divs[1])
			baner_divs[1].style.zIndex= 1;	
		if(baner_divs[0])
			baner_divs[0].style.zIndex= 0;		
		if(baner_divs[2])
			baner_divs[2].style.zIndex= 0;			
	} else if(obj.id == 'banner3') {
		turntopage = 3;
		if(baner_divs[2])
			baner_divs[2].style.zIndex= 1;	
		if(baner_divs[0])
			baner_divs[0].style.zIndex= 0;	
		if(baner_divs[1])
			baner_divs[1].style.zIndex= 0;			
	}
		obj.className = "selected";
		actBanner = obj.id;
		pid = actBanner.substring(6,7);
		alert("Hello")
		//featuredcontentslider.buildpaginate(setting);
		//alert("HIIII"+window["fcsfade"+setting.id])
		//featuredcontentslider.cleartimer(window["fcsfade"+setting.id]);
		//this.autorotate();
		alert("Hiii")
		/*featuredcontentslider.init();
		setting.prevpage=turntopage
		if (featuredcontentslider.enablepersist)
			featuredcontentslider.setCookie("fcspersist"+setting.id, turntopage)*/
	//clickchange(pid);
	//alert(nid);
	//xmlhttpPost(nid,'home')
}

function update_hit_count(banner_id)
{
	xmlhttpPost(banner_id);
}

function xmlhttpPost(nid,banner_type) {
    var xmlHttpReq = false;
    var self = this;
		//alert("hi1"+nid+banner_type);
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	strURL = Drupal.settings.basePath + "update_hit_count";
	//alert(strURL);
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			//alert("updated"+self.xmlHttpReq.responseText);           
        }
    }
	qstr = 'id='+nid+'&banner_type='+banner_type;
    self.xmlHttpReq.send(qstr);
}
function getquerystring() {
    var form     = document.forms['f1'];
    var word = form.word.value;
    qstr = 'w=' + escape(word);  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage(str){
    document.getElementById("result").innerHTML = str;
}


function get_location_names(strcity)
{
	alert(strcity);
	xmlhttpPostCity(strcity);
}

function xmlhttpPostCity(strcity) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	curr_lang = Drupal.settings.curr_lang;	 
	if(curr_lang.indexOf("ar") == 0)
		strURL = Drupal.settings.basePath + "ar/get_loc_name";
	else
		strURL = Drupal.settings.basePath + "get_loc_name";

	//alert(strURL);
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			locoptstr = self.xmlHttpReq.responseText;
			document.getElementById('dvloc_name').innerHTML = locoptstr;
			//alert(self.xmlHttpReq.responseText);           
        }
    }
	qstr = 'city='+strcity;
    self.xmlHttpReq.send(qstr);
}

function css(el, targetclass, action){
	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
	if (action=="check")
		return needle.test(el.className)
	else if (action=="remove"){
		el.className=el.className.replace("selected", "")
	}
	else if (action=="add"){
		el.className+=""+targetclass
	}
}

function buildcontentdivs(){
	if(!document.getElementById("slider1"))
		return;
	var alldivs=document.getElementById("slider1").getElementsByTagName("div")	
	var contentdivs = new Array();
	for (var i=0; i<alldivs.length; i++){		
		if (this.css(alldivs[i], "contentdiv", "check")){ //check for DIVs with class "contentdiv"
			contentdivs.push(alldivs[i])
		}
	}
	return contentdivs;
}
//-->
//Common jquery will come here .. 
$(document).ready(function() {
	// way to bank onselect redirect to other page
	$('#waytobankselect').change(function() {
	  window.location = $(this).val();
	});
	
	// code for show specific submenu 
	 showmenu = Drupal.settings.show_submenu;	 
	 active_menu = Drupal.settings.active_menu;	
	 active_submenu = Drupal.settings.active_submenu;	
	// alert(active_submenu);
	 if(showmenu == null)
	 	showmenu ='block-views-3a428eda57e5283db51b524958b6f453';
	//show deault first submenu
	$('#'+showmenu).show();	
	
	if($("#callout3").find('.block').length == 3){
		$("#tabcallouts").addClass('hightissue');
	}

	//move submenu div inside menu div.
	$('#topNavBg .mainNav').append($('.subMenuNav'));
	//add span for main menu & set active for product & submenu pages
	var Menucnt = 1;
	$('#topNavBg .mainNav .view-content .item-list ul li .views-field-title a').each(function(i){
			   var divtext = $(this).text();
			   $(this).wrapInner('<span></span>') ;

			// Add active class to main menu
			//alert(Menucnt +' '+ active_menu);
			if(Menucnt == active_menu)
				$(this).addClass('active')
			Menucnt++;
	});
	//set submenu active for product pages
	$('#'+showmenu +' .view-content .item-list ul li').each(function(i){
			// Add active class to main menu
			if(parseInt($(this).find(".views-field-nid span").text()) == active_submenu)
			{
				$(this).find("a").addClass('active');
			}
	});
	
	//open scaned link in new window
	$('.field-field-scanned-article a').attr('TARGET', '_blank');	
	
	$("#webform-client-form-252 #edit-submit").attr('value', '');
	$(".views-view-grid tr").each(function(e){
//		alert(e);
		$(".views-view-grid .row-" + (e+1) + " .col-1 .linkgblock .views-field-body").prepend($(".views-view-grid .row-" + (e+1) + " .col-1 .linkgblock .views-field-title"));
		$(".views-view-grid .row-" + (e+1) + " .col-2 .linkgblock .views-field-body").prepend($(".views-view-grid .row-" + (e+1) + " .col-2 .linkgblock .views-field-title"));
	});
	
	$("#block-views-home_callout_bb-block_1 #homecalloutlink a").addClass("n1");
	$("#block-views-home_callout_cb-block_1 #homecalloutlink a").addClass("n1");
	
	//alert($("#homecalloutlink").html());
        fixViewsTabs();
        fixTopMenuBorder();
 });

function fixViewsTabs() {
	$('div.contentBody #tabs-tabset ul.tabs li a').click(function() {$(this).parent().siblings().removeClass('active');});
}

function fixTopMenuBorder() {
	$('ul.menu > li.expanded > a').hover(function() {												   
		$(this).css('border','1px solid #21BCFF');
		//$(this).css('border','1px solid #0f0');
	},function() {
		$(this).css('border','1px solid #fff');		
	});
	
	$('ul.menu > li.expanded > ul.menu > li').hover(function() {
		//$(this).parent().prev().css('border','1px solid #f00');
		$(this).parent().prev().css('border','1px solid #21BCFF');
	},function() {
		var a = $(this).parent().prev();
		a.css('border','1px solid #fff');
	});
}


