﻿ function SwitchTab(index,count, uniquename)
        {
	        for (i=0;i<=count;i++)  {
		        if (i==index)   {
    			    table = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xTable'+i);
    			    if (table) {table.style.display='';}
			        tab = document.getElementById('ctl00_ctl00_cphContent_cphContentRight_xTab'+i);     
			        if (tab) {tab.className='left_menu_item_sel';}    
		        }
		        else
		        {
    			    table = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xTable'+i);
    			    if (table) {table.style.display='none';}
			        tab = document.getElementById('ctl00_ctl00_cphContent_cphContentRight_xTab'+i);     
			        if (tab) {tab.className='left_menu_item';}    
		        }
	        }
	        
	        custom3 = uniquename;
	        
//	        window.document.cookie = "regPageCookie="+custom3+"; expires="+xExpiration.toGMTString()+"; path=/";	
	        updateStatus = true;

/*
	        if(custom3==logname+'-Pricing')
	        {
	            intializeCookieRead();
	            CustomUpdate(0,refId);
	        }	
*/	        
        }

function SwitchWSOpTab(index,count)
        {
	        for (i=0;i<=count;i++)
	        {
		        if (i==index) 
    		    {
    			    table = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xSubTable'+i);
    			    if (table) {table.style.display='';}
    			    tabl = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_wsoptablt'+i);
			        tab = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_wsoptab'+i);   
			        tabr = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_wsoptabrt'+i);  
			        if (tabl) {tabl.className='wsoptablt_sel';}
			        if (tab) {tab.className='wsoptab_sel';}
			        if (tabr) {tabr.className='wsoptabrt_sel';}
			            
		        }
		        else
		        {
    			    table = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xSubTable'+i);
    			    if (table) {table.style.display='none';}
    			    tabl = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_wsoptablt'+i);
			        tab = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_wsoptab'+i);   
			        tabr = document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_wsoptabrt'+i);  
			        if (tabl) {tabl.className='wsoptablt';}
			        if (tab) {tab.className='wsoptab';}
			        if (tabr) {tabr.className='wsoptabrt';}   
		        }
	        }
        }

function isEnterKey(evt)
{
    evt = (evt) ? evt : (window.event) ? window.event : "";
    var theKey;
    if (evt) {
        theKey = (evt.which) ? evt.which : evt.keyCode;
    }
    return (theKey == 13);
}

function ProcessOnEnter(fld, evt)
{
    if (isEnterKey(evt)) {
        SubmitSearch();
        return false;
    }
    return true;    
}

function SubmitSearch()
{
    var url="/Search.aspx?search="
    
    var strSearchCtrl = document.getElementById('ctl00_SearchTextBox')
    
    if (strSearchCtrl != null)
    {
		// needs to escape the string first to avoid invalid characters to get through the search field.
        url = url + escape(strSearchCtrl.value);
    }
	window.location.href=url;  
    return;
}

function SubmitEditGrid(url)
{
	// using div - new method
    var inputs= document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xform').getElementsByTagName('INPUT');
	var selects= document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xform').getElementsByTagName('SELECT');
	    
	var inputcount = inputs.length;
	var selectcount = selects.length;
	
	var namePrefixStr = "ctl00$ctl00$cphContent$cphContentLeft_";
	var namePrefixLen = namePrefixStr.length;
	var idPrefixStr = "ctl00_ctl00_cphContent_cphContentLeft_";
	var idPrefixLen = idPrefixStr.length;
	var newinputid = '';
	var longid = '';
	var newinputname = '';
	var longname = '';
	
	var sep = "&";
	
	var validateresult = true;
	var strError = "";
	
	for (i = 0; i < inputcount; i++)
	{
	    var input = inputs[i];
	    
	    if (input.id!='')
	    {
	        longid = input.id;
	        newinputid = longid.substr(idPrefixLen);
	        //if (input.value!='') 
	   		//{
	   		    if (input.type=='radio')
	   			{
	   			    if (input.checked==true)
		   			{
		   			    longname = input.name;
		   			    newinputname = longname.substr(namePrefixLen);
		   			    
			   		    if (input.value=='false')
		   				{
				    	    url= url+ sep + newinputname +"=false";
			   			}
			   			else
			   			{
				    	    url= url+ sep + newinputname +"=true";
			   			}
			   			sep = "&";
			   		}
	   			}   
	   			else
	   			{
	   				// needs to validate the input first 
	   				strError = validateInputField(newinputid, input.value, strError);
			    	url= url+ sep + newinputid +"="+ escape(input.value);
			   		sep = "&";
	   			}
	   		//}	
	    }
    }
    if (strError.length > 1) 
    {
        alert(strError);
		return false;
    }
	for (i = 0; i<selectcount; i++)
	{
	    var input = selects[i];
	    longid = input.id;
	    newinputid = longid.substr(idPrefixLen);
	        
	    if (input.id!='')
	    {
	   	   // if (input.value!='') 
	   	   //{
		        url= url+ sep + newinputid +"="+escape(input.value);
	   		    sep = "&";
	   	   //}
	   	}
	}    

    window.open(url, "TestForm");
}

function SubmitHTML()
{
	var url = '/Misc/xHTML.aspx?xService='+document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xService').value+"&xOperation="+document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xOperation').value;


	// using div - new method
	var inputs= document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xform').getElementsByTagName('INPUT');
	var selects= document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xform').getElementsByTagName('SELECT');
	
	// using form - old method
    // var inputs= document.forms['ctl00_ctl00_cphContent_cphContentLeft_xform'].getElementsByTagName('INPUT');
	// var selects= document.forms['ctl00_ctl00_cphContent_cphContentLeft_xform'].getElementsByTagName('SELECT');
	var inputcount = inputs.length;
	var selectcount = selects.length;
	
	var namePrefixStr = "ctl00$ctl00$cphContent$cphContentLeft_";
	var namePrefixLen = namePrefixStr.length;
	var idPrefixStr = "ctl00_ctl00_cphContent_cphContentLeft_";
	var idPrefixLen = idPrefixStr.length;
	var newinputid = '';
	var longid = '';
	var newinputname = '';
	var longname = '';
	
	var validateresult = true;
	var strError = "";	
		
	for (i = 0; i<inputcount; i++)
	{
	    var input = inputs[i];
	   	if (input.id!='')
	   	{
	        longid = input.id;
	        newinputid = longid.substr(idPrefixLen);
	        if (input.id[0]!='x' && input.id!='search' && input.id!='xOperation' && input.value!='')  
	   		{

	   		    if (input.type=='radio')
	   			{
   				    if (input.checked==true)
		   			{
		   		        longname = input.name;
		   			    newinputname = longname.substr(namePrefixLen);	
			   		    
			   		    if (input.value=='false')
		   				{
				    	    url= url+ "&" + newinputname +"=false";
			   			}
			   			else
			   			{
				    	    url= url+ "&" + newinputname +"=true";
			   			}
			   		}
	   		    }   
	   			else
	   			{
	   				strError = validateInputField(newinputid, input.value, strError);
			    	url= url+ "&" + newinputid +"="+escape(input.value);
	   			}
	   		}	
	   	}
    }
    if (strError.length > 1) 
    {
        alert(strError);
		return false;
    }
	for (i = 0; i<selectcount; i++)
	{
	    var input = selects[i];
	    longid = input.id;
	    newinputid = longid.substr(idPrefixLen);
	    
	    if (input.id!='')
	    {
		    if (input.id[0]!='x' && input.id!='search' && input.id!='xOperation' && input.value!='') 
		    {
	       	    url= url+"&"+ newinputid +"="+escape(input.value);
	   	    }
	    }
	}

    window.open(url, "TestForm");
	// window.location.href=url;
}	



function SubmitXML(xurl)
{
    var url = xurl;

	// using div - new method
    var inputs= document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xform').getElementsByTagName('INPUT');
	var selects= document.getElementById('ctl00_ctl00_cphContent_cphContentLeft_xform').getElementsByTagName('SELECT');
	    
	var inputcount = inputs.length;
	var selectcount = selects.length;
	
	var namePrefixStr = "ctl00$ctl00$cphContent$cphContentLeft_";
	var namePrefixLen = namePrefixStr.length;
	var idPrefixStr = "ctl00_ctl00_cphContent_cphContentLeft_";
	var idPrefixLen = idPrefixStr.length;
	var newinputid = '';
	var longid = '';
	var newinputname = '';
	var longname = '';
	
	var sep = "?";
	
	var validateresult = true;
	var strError = "";
	
	for (i = 0; i < inputcount; i++)
	{
	    var input = inputs[i];
	    
	    if (input.id!='')
	    {
	        longid = input.id;
	        newinputid = longid.substr(idPrefixLen);
	        //if (input.value!='') 
	   		//{
	   		    if (input.type=='radio')
	   			{
	   			    if (input.checked==true)
		   			{
		   			    longname = input.name;
		   			    newinputname = longname.substr(namePrefixLen);
		   			    
			   		    if (input.value=='false')
		   				{
				    	    url= url+ sep + newinputname +"=false";
			   			}
			   			else
			   			{
				    	    url= url+ sep + newinputname +"=true";
			   			}
			   			sep = "&";
			   		}
	   			}   
	   			else
	   			{
	   				// needs to validate the input first 
	   				strError = validateInputField(newinputid, input.value, strError);
			    	url= url+ sep + newinputid +"="+ escape(input.value);
			   		sep = "&";
	   			}
	   		//}	
	    }
    }
    if (strError.length > 1) 
    {
        alert(strError);
		return false;
    }
	for (i = 0; i<selectcount; i++)
	{
	    var input = selects[i];
	    longid = input.id;
	    newinputid = longid.substr(idPrefixLen);
	        
	    if (input.id!='')
	    {
	   	   // if (input.value!='') 
	   	   //{
		        url= url+ sep + newinputid +"="+escape(input.value);
	   		    sep = "&";
	   	   //}
	   	}
	}    

    window.open(url, "TestForm");
	    
}

function SubmitDemo(xurl)
{
    var url = xurl;

	// using div - new method
    var obj = document.getElementById('Param');
	var strError = "";

    if (obj) 
    {
		// needs to validate the input first 
		strError = validateInputField(obj.name, obj.value, strError);
		// encode the input value before sending to server for processing
        url = url + "&Param=" + escape(obj.value);
        
        if (strError.length > 1) 
		{
			alert(strError);
			return false;
		}
    }
	
	//window.open(url, "Demo");
	window.location.href=url;
		
    
}
