function changePage(page) {
    var q_string = "?";

    if ( document.frmSearch.length ) {
        e_count = document.frmSearch.length;
        for(i=0; i<e_count; i++){
            q_string += document.frmSearch[i].name +'='+ document.frmSearch[i].value +'&';
        }
    }

    if ( page != "" && page > 0 ) {
        q_string += "&x="+ page;
    }
    else {
        q_string += "&x=1";
    }
    window.location.href = q_string;
    
    return false;
}
/*
function changePageWithExtra(page,string_e) {
    var q_string = "?";
    
    if ( page != "" && page > 0 ) {
        q_string += "&x="+ page;
    }
    else {
        q_string += "&x=1";
    }
    
    // extra url variables pass    
    q_string+= string_e ;
    window.location.href = q_string;
    return false;
}
*/


function changePageWithExtra(page,string_e) {
    //var q_string = "?";
  var q_string = "";
    

    //if ( document.frmSearch.length ) {
      //  e_count = document.frmSearch.length;
      //  for(i=0; i<e_count; i++){
     //       q_string += document.frmSearch[i].name +'='+ document.frmSearch[i].value +'&';
     //   }
    //}
   
    
    if ( page != "" && page > 0 ) {
        q_string += "&x="+ page;
    }
    else {
        q_string += "&x=1";
    }
   
    // extra url variables pass    
     q_string+= string_e ;	
     sub_url= window.location.href ;	
	 pos =  sub_url.indexOf('?');
	
	if(navigator.appName.indexOf("Microsoft")!=-1){
		if(navigator.appVersion.indexOf("MSIE 6.0") !=-1){
			document.write();
		}
	}
	 //document.write();
	 if(pos >= 0){
		  pos = parseInt(pos);
          sub_url = sub_url.substr(0,pos);		
		  url = sub_url+"?"+q_string;		  
	 }else{
		  url = sub_url+"?"+q_string ;
	 }
	
	window.location = url;
    return true;   
}

function gotoURL(url) {
    document.location = url;
}


function reallyDel(str) {
	if ( !str ) {
		str = "Do you really want to DELETE?";
	}
	if ( confirm(str) ) {
		return true;
	}
	return false;
}


function selectOnlyOne( element ) {
	var el = document.getElementsByName(element.name) ;
	for( i=0; i<el.length; i++ ) {
		if ( el[i].value != element.value ) {
			el[i].checked = false;
		}
	}	
}

function selectAtleastOne( element ) {
    var el = document.getElementsByName(element.name) ;
    for( i=0; i<el.length; i++ ) {
        //if ( el[i].value != element.value ) {
        if ( el[i] != element ) {
            el[i].checked = false;
        }
        else if ( el[i] == element ) {
            el[i].checked = true;
        }
    }
}

function hideSelect() {
	var select_arr = window.document.getElementsByTagName("select");
	for (i=0; i<select_arr.length; i++) {
		select_arr[i].style.visibility = 'hidden';
	}
}
function showSelect() {
	var select_arr = window.document.getElementsByTagName("select");
	for (i=0; i<select_arr.length; i++) {
		select_arr[i].style.visibility = 'visible';
	}
}


/**
 * function onlyNumerics(e)
 * This function is used to restrict the input characters to 
 * digits [0-9] only, anyother key is neglected.
 *
 * @param	e		This is the Event object that has occurred. 
 *					This is mainly a hack for Mozilla browsers, in Internet Explorer it is not required.
 *
 * @return	boolean	true, if the key is accepted.
 *					false, if the key is not accepted.
 */
function onlyNumerics(e){

	var e = e? e : window.event;
	if(!e) 
		return;
	
	var key = 0;
	if (e.keycode) { 
		key = e.keycode; 
	} // for moz/fb, if keycode==0 use 'which'
	else if (typeof(e.which)!= 'undefined') { 
		key = e.which; 
	} 
	//alert(key);
	if ( (key>=46 && key<=57) || key == 8 || key ==0 ){
		return (true) ;
	}
	else{
		return (false);	
	}
}


/**
 * function onlyNumerics(e)
 * This function is used to restrict the input characters to 
 * digits [0-9] only, anyother key is neglected.
 *
 * @param	e		This is the Event object that has occurred. 
 *					This is mainly a hack for Mozilla browsers, in Internet Explorer it is not required.
 *
 * @return	boolean	true, if the key is accepted.
 *					false, if the key is not accepted.
 */
function onlyCharacters(e){
 
	var e = e? e : window.event;
  
	if(!e) 
		return;
	
	var key = 0;
	if (e.keycode) { 
		key = e.keycode; 
       
	} // for moz/fb, if keycode==0 use 'which'
	else if (typeof(e.which)!= 'undefined') { 
		key = e.which; 
	} 
   
	//alert(key);
    // 32 for space, A=65-Z=90 , a=97-z=122 
	if ( (key>=65 && key<=90) || (key>=97 && key<=122) || key == 8 || key ==0 || key==32){
		return (true) ;
	}
	else{
		return (false);	
	}
}


/**
 * function onlyClear(e)
 * This function is used to allow only Delete key event.
 *
 * @param   e       This is the Event object that has occurred. 
 *                  This is mainly a hack for Mozilla browsers, in Internet Explorer it is not required.
 *
 * @return  boolean true, if the key is accepted.
 *                  false, if the key is not accepted.
 */
function onlyClear(e){
    var e = e? e : window.event;
    if(!e) 
    return;
    
    var key = 0;
    if (e.keycode) { 
        key = e.keycode; 
    } // for moz/fb, if keycode==0 use 'which'
    else if (typeof(e.which)!= 'undefined') { 
        key = e.which; 
    } 
    //alert(key);
    if ( key==8 || key==0 ){
        return (true) ;
    }
    else{
        return (false); 
    }
}


function clearField(element) {
    if (element.value = '') {
        return true;
    }
    else {
        return false;
    }
}

/**
 * function toggleVisibilityOfElement( element )
 *
 * This function is used to change the visibility of 
 * element, where the "visible" and "hidden" and the 
 * css stylesheet entities having display property 
 * as "block" and "hidden" resp.
 */
function toggleVisibilityOfElement( element ) {
	if ( element.className == "visible" ) {	
		element.className = "hidden";
	}
	else {
		element.className = "visible";
	}
}


function toggleSelection( id ) {
    element = document.getElementById(id)
    if ( count = element.length ) {
        for (i=0; i>count; i++ ) {
            element[i].checked = !element[i].checked;
        }
    }
    
    return (true);
}
// toggleSelection('r_{$id}[]')
    function selectAll(parent, parent_div_title, element_name) {
        element = this.window.document.getElementsByName(element_name);
        if ( parent.checked ) {
            boolean = true;
        }
        else {
            boolean = false;
        }
        for ( i=0;i<element.length;i++) {
            if (parent_div_title == element[i].parentNode.title) {
                element[i].checked = boolean;
            }
        }
    }

/**
 * This function is used to create the query string format of 
 * all the elements that are present within the scope of the 
 * form that has been passed as an argument.
 *
 * @param	form element	The form for which the query string is to be created.
 *
 * @return	querystring		the querystring format of all the elements is retunred back.
 */

function createQueryString(form) {
	var query_string = "";
	for (var i = 0; i < form.elements.length; i++) {

		switch (form.elements[i].type) {
			case ("text"): {
				if ( form.elements[i].value != "" ) {
					query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
				}
				break;
			}
			case ("textarea"): {
				if ( form.elements[i].value != "" ) {
					query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
				}
				break;
			}
			case ("hidden"): {
				if ( form.elements[i].value != "" ) {
					query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
				}
				break;
			}
			case ("checkbox"): {
				if ( form.elements[i].checked ) {
					query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
				}
				break;
			}
			case ("select-one"): {
				query_string += "&"+ form.elements[i].name 
									+"="+ form.elements[i].options[form.elements[i].selectedIndex].value;
				break;
			}
			case ("select-multiple"): {
				s_options = "";
				for ( j=0; j < form.elements[i].length; j++ ) {
					if ( form.elements[i].options[j].selected ) {
						s_options += ","+ form.elements[i].options[j].value;
					}
				}
				if (s_options != "") {
					s_options = s_options.substr(1);
					query_string += "&"+ form.elements[i].name +"="+ s_options;
				}
				break;
			}
			case ("radio"): {
				if ( form.elements[i].checked ) {
					query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
				}
				break;
			}
/*			case ("submit"): {
				if ( form.elements[i].value != "" ) {
					query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
				}
				break;
			}*/
		}
	}
	return (query_string);
}

function uncheckOpt(ename){
    var el = document.getElementsByName(ename) ;
    for( i=0; i<el.length; i++ ) {
        if ( el[i].checked= true ) {
            el[i].checked = false;
        }
       
    }
}
function movePage(page,xvar,string_e) {
    var q_string = "?";
    
    
    if ( page != "" && page > 0 ) {
        q_string += "&"+xvar+"="+ page;
       // q_string += "&x="+ page;
    }
    else {
        q_string += "&"+xvar+"=1";
       // q_string += "&x=1";
    }
   
    // extra url variables pass    
    q_string+= string_e ;
    window.location.href = q_string;
    return false;
}

/*
js for left menu BOF 

*/




function toggleVisibilityOfMenu( id ) {
    element = document.getElementById(id);
	if ( element.className == "visible" ) {
		element.className = "hidden";
	}
	else {
		element.className = "visible";
	}
}

function toggleMenu(menuid) {
    element = document.getElementById(menuid);
    var winWh;
    var winW;    
    var winHv;
     var winWvm
    if (parseInt(navigator.appVersion) >3) {
         if (navigator.appName=="Netscape") {
          winW = parseInt(window.innerWidth) ;
          winWh = parseInt(window.innerWidth) -45 ;
          winWv = parseInt(window.innerWidth) - 270;
          winH = parseInt(window.innerHeight) - 40;
          winHS = parseInt(window.innerHeight) - 47;
          winWvm= parseInt(winWv) - 25;
         }
         if (navigator.appName.indexOf("Microsoft")!=-1) {
         
          winW = parseInt(document.body.offsetWidth) - 20;
          winWh = parseInt(winW) - 45;
          winWv = parseInt(winW) - 280;
          winH = parseInt(document.body.offsetHeight)  - 50;
          winHS = parseInt(document.body.offsetHeight)  - 57;
          winWvm= parseInt(winWv) - 40;
         }
    }
    
  
    
    
   	if ( element.className == "visible" ) {
      
        element.className = "hidden";    
        document.getElementById('content01').style.width=winW+"px";
        document.getElementById('content01').style.height=winH+"px";
        document.getElementById('mainId').style.width = winWh+"px";
        document.getElementById('mainId').style.height=winHS+"px";
        document.getElementById('subMainId').style.width=winWh+"px";
        document.getElementById('subMainId').style.height=winHS+"px";       
        document.getElementById('showMenuButton').style.height=winH+"px";
	}
	else {
       
		element.className = "visible";
        document.getElementById('content01').style.width=winWv+"px";       
        document.getElementById('content01').style.height=winH+"px";     
        document.getElementById('mainId').style.width= winWvm+"px";
        document.getElementById('mainId').style.height=winHS+"px";      
        document.getElementById('subMainId').style.width= winWvm+"px";
        document.getElementById('subMainId').style.height=winHS+"px";         
        document.getElementById('showMenuButton').style.height=winH+"px";
        
	}
      
}

function setHtWidth(){

    var winW;
    var winWM;
    var winH;
    var winHS;
    if (parseInt(navigator.appVersion)>3) {
         if (navigator.appName=="Netscape") {
          
            winW = parseInt(window.innerWidth) - 270;
            winWM = parseInt(window.innerWidth) - 300; //For mainId
            winHS = parseInt(window.innerHeight) - 47;
            winH = parseInt(window.innerHeight) - 40;
        }
         
        if (navigator.appName.indexOf("Microsoft")!=-1) {
          
          winW = parseInt(document.body.offsetWidth) - 280;
          winWM = parseInt(document.body.offsetWidth) - 320; //For mainId
          winHS =  parseInt(document.body.offsetHeight) - 57;
          winH =  parseInt(document.body.offsetHeight) - 50;
        }
    }

    
    
    document.getElementById('content01').style.width = winW+"px";       
    document.getElementById('mainId').style.width=winWM+"px";
    document.getElementById('subMainId').style.width=winWM+"px";
    document.getElementById('showMenuButton').style.height=winH+"px";
    
    document.getElementById('content_div').style.height=winH+"px";
    document.getElementById('showMenuButton').style.height=winH+"px";
    document.getElementById('middleId').style.height=winH+"px";
    document.getElementById('content01').style.height=winH+"px";
    document.getElementById('mainId').style.height=winHS+"px";
    document.getElementById('subMainId').style.height=winHS+"px";
    
    
    
}

/*
js for left menu EOF

*/
//To display POPUP window in center bof
function openSmallWindow(url,vwidth,vheight)
{
        if(vwidth=="0") {vwidth=250; }
        if(vheight=="0") {vheight=250; }
        var win_param;	
        LeftPosition = (screen.width) ? (screen.width-vwidth)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-vheight)/2 : 0;       
        win_param="top="+TopPosition+",left="+LeftPosition+",width="+vwidth+",height="+vheight+"channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,screenX=0,left=75,top=75,screenY=0";
        msgWindow=open(url,"SmallWindow",win_param);
        msgWindow.focus();
        msgWindow.opener= self;
        return false;
}
//To display POPUP window in center eof



/*2009-7-july-21 js For index.html bof*/

function toggle() {
	
	if (parseInt(navigator.appVersion)>3) {
         if (navigator.appName=="Netscape") {
            w = parseInt(window.innerWidth) ;
            h = parseInt(window.innerHeight) ;
        }
         
        if (navigator.appName.indexOf("Microsoft")!=-1) {
            w  = parseInt(document.body.offsetWidth) ;
            h  =  parseInt(document.body.offsetHeight) ;
        } 
    }
  
	if(document.getElementById('left'))
	{
         var contentw = w-62 ;
         var icontentw = w-70;
		 document.getElementById('content').style.width = contentw+"px";
		 document.getElementById('inner_content').style.width = icontentw+"px"; 
		 document.getElementById('home_page').style.width =icontentw+"px";
         document.getElementById('menu').style.display = 'none';
		 document.getElementById('arrow_left').src = '../media/images/nc/middle-arrow-right.jpg';
		 document.getElementById('left').id='right';
	}else{
         var contentw = w-315 ;
         var icontentw = w-323;
		 document.getElementById('content').style.width =contentw+"px";
		 document.getElementById('inner_content').style.width = icontentw+"px";
		 document.getElementById('home_page').style.width = icontentw+"px";
		 document.getElementById('menu').style.display = 'block';
		 document.getElementById('arrow_left').src = '../media/images/nc/middle-arrow-left.jpg';
		 document.getElementById('right').id='left';
	}
}

function fun1() {
    /*
	var h=screen.height;
	var w=screen.width;
	*/
      if (parseInt(navigator.appVersion)>3) {
         if (navigator.appName=="Netscape") {
            w = parseInt(window.innerWidth) ;
            h = parseInt(window.innerHeight) ;
            var contentw = w-315 ;
            var contenth = h ;
            var icontentw = w-323;
            document.getElementById('menu').style.height = contenth+"px";
            document.getElementById('arrow').style.height = contenth+"px";
            document.getElementById('content').style.height = contenth+"px";
        }
         
        if (navigator.appName.indexOf("Microsoft")!=-1) {
            w  = parseInt(document.body.offsetWidth) ;
            h  =  parseInt(document.body.offsetHeight) ;
            var contentw = w-315 ;
            var contenth = h ;
            var icontentw = w-323;
            document.getElementById('menu').style.height = "100%";
            document.getElementById('arrow').style.height = "100%";
            document.getElementById('content').style.height = "100%";
        } 
    }
  
    /*var contentw = w-315 ;
    var contenth = h ;
    var icontentw = w-323;*/
	document.getElementById('content').style.width = contentw+"px";
	//document.getElementById('content').style.height = contenth+"px";
	//document.getElementById('arrow').style.height = contenth+"px";
	//document.getElementById('menu').style.height = contenth+"px";
    /*document.getElementById('content').style.height = "100%";
	document.getElementById('arrow').style.height = "100%";*/
	//document.getElementById('menu').style.height = "100%";
	document.getElementById('inner_content').style.display = 'none';
	document.getElementById('inner_content').style.width = icontentw+"px";	

    var displayLanding= document.getElementById('display').value;
    
    if(displayLanding==1){	   
      	var delay = setTimeout("fun2()",3000);	
    }
    
    if(displayLanding==0){
       document.getElementById('home_page').style.display = 'none';
       document.getElementById('inner_content').style.display = 'block';
       document.getElementById('navigation').style.display = 'block';
    }
    
}

function fun2() {
	document.getElementById('home_page').style.display = 'none';
	document.getElementById('inner_content').style.display = 'block';
    document.getElementById('navigation').style.display = 'block';
    //document.getElementById('navigation').style.display = 'block';
}

/*2009-7-july-21 js For index.html eof*/

function cleanState(id) {
	var state;	
	state = document.getElementById(id);	
	
	if (state.value == "First Name" || state.value == "Last Name" || state.value == "Company" || state.value == "Address" || state.value == "City" || state.value == "State" || state.value == "Phone/Mobile" || state.value == "Email" || state.value == "Comments" || state.value == "Verify")
    {	  	  	
        state.value = "";
        state.style.color = "#3a3737";
	    state.style.fontWeight = "bold";
    }
}

function changeState(id) {
	var state;	
	state = document.getElementById(id);	
	
    state.style.color = "#3a3737";
	state.style.fontWeight = "bold";
    
    if(id == 'first_name_id'){
        if(!(state.value))
        {
            state.value = "First Name";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    
    if(id == 'last_name_id'){
        if(!(state.value))
        {
            state.value = "Last Name";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    
    if(id == 'firm'){
        if(!(state.value))
        {
            state.value = "Company";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    
    if(id == 'address'){
        if(!(state.value))
        {
            state.value = "Address";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    
    if(id == 'city'){
        if(!(state.value))
        {
            state.value = "City";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    
    if(id == 'state'){
        if(!(state.value))
        {
            state.value = "State";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    
     if(id == 'contact_no'){
        if(!(state.value))
        {
            state.value = "Phone/Mobile";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    
    if(id == 'email'){
        if(!(state.value))
        {
            state.value = "Email";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    
    if(id == 'comments'){
        if(!(state.value))
        {
            state.value = "Comments";
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    if(id == 'salutation'){
        if(!(state.value))
        {
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    if(id == 'country'){
        if(!(state.value))
        {
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
    if(id == 'calculate'){
        if(!(state.value))
        {
            state.style.color = "#989494";
	        state.style.fontWeight = "normal";
        }
    }
}

