//
//	***************************************************************************
//	**	CREATED BY  : TEJAL SHARMA    01/10/2007		   			         **
//	**	APPLICATION : INDEPENDENT											 **
//	**	COMMENTS    : THIS JS IS FOR QUERING XML DOCUMENTS					 **
//	**																		 **
//	***************************************************************************
//
/*Contact us page*/
function checkValues()
    {
        var param = "";
        if(document.getElementById('ctl00_ContentPlaceHolder1_txtName').value=='')
        {
            alert('Provide your Name');
            document.getElementById('ctl00_ContentPlaceHolder1_txtName').focus();
            return false;
        }
        param =  document.getElementById('ctl00_ContentPlaceHolder1_txtName').value + '$$'
        if(document.getElementById('ctl00_ContentPlaceHolder1_txtContactNo').value=='')
        {
            alert('Provide your Contat No.');
            document.getElementById('ctl00_ContentPlaceHolder1_txtContactNo').focus();
            return false;
        }
        param = param + document.getElementById('ctl00_ContentPlaceHolder1_txtContactNo').value + '$$'
        if(document.getElementById('ctl00_ContentPlaceHolder1_txtCountry').value=='')
        {
            alert('Provide your Country');
            document.getElementById('ctl00_ContentPlaceHolder1_txtCountry').focus();
            return false;
        }
        param = param + document.getElementById('ctl00_ContentPlaceHolder1_txtCountry').value + '$$'
        if(document.getElementById('ctl00_ContentPlaceHolder1_txtEmail').value=='')
        {
            alert('Provide your Email');
            document.getElementById('ctl00_ContentPlaceHolder1_txtEmail').focus();
            return false;
        }
        param = param + document.getElementById('ctl00_ContentPlaceHolder1_txtEmail').value + '$$'
        if(document.getElementById('ctl00_ContentPlaceHolder1_txtEnquiry').value=='')
        {
            alert('Provide your Query');
            document.getElementById('ctl00_ContentPlaceHolder1_txtEnquiry').focus();
            return false;
        }
        
        param = param + document.getElementById('ctl00_ContentPlaceHolder1_txtEnquiry').value     
//        var qry='GetXML.aspx?qryID=3&Param='+param;
//       // alert(qry);
//        var xmlClientID=init(qry);
//         //alert(xmlClientID);
//         xmlClientID=null;
         var qry='../GetXML.aspx?qryID=4&Param='+param;
         var xmlClientID=init(qry);
        
        alert('Thank you. We will get back to you soon');
        return false;
    }
/*Contact us page ends here*/
/*Product detail page javasript*/

function showDiv()
{
    alert('Coming Soon');
    //$.modal("<div><h1>SimpleModal</h1></div>");

  // $('<div>my data</div>').modal();
  //  $('#testdiv').modal({onOpen:modalOpen});
}
  function switchTab(tabID,liID)
    {
        if(tabID == 'divDescription'){
            document.getElementById('divDescription').style.display = "block";
            document.getElementById('divCare').style.display = "none";
            document.getElementById('divPackaging').style.display = "none";
            document.getElementById('divInsurance').style.display = "none";
            document.getElementById('divPaymentMethods').style.display = "none";
            document.getElementById(liID).className="selected";
            document.getElementById('liCare').className="";
            document.getElementById('liPackaging').className="";
            document.getElementById('liInsurance').className="";
            document.getElementById('liPaymentMethods').className="";
        }else if(tabID == 'divCare'){
            document.getElementById('divDescription').style.display =  "none";
            document.getElementById('divCare').style.display = "block";
            document.getElementById('divPackaging').style.display = "none";
            document.getElementById('divInsurance').style.display = "none";
            document.getElementById('divPaymentMethods').style.display="none"
            document.getElementById(liID).className="selected";
            document.getElementById('liDescription').className="";
            document.getElementById('liPackaging').className="";
            document.getElementById('liInsurance').className="";
            document.getElementById('liPaymentMethods').className="";
        }else if(tabID == 'divPackaging'){
            document.getElementById('divDescription').style.display =  "none";
            document.getElementById('divCare').style.display = "none";
            document.getElementById('divPackaging').style.display = "block";
            document.getElementById('divInsurance').style.display = "none";
            document.getElementById('divPaymentMethods').style.display="none";
            document.getElementById(liID).className="selected";
            document.getElementById('liDescription').className="";
            document.getElementById('liCare').className="";
            document.getElementById('liInsurance').className="";
            document.getElementById('liPaymentMethods').className="";
        }else if(tabID == 'divInsurance'){
            document.getElementById('divDescription').style.display =  "none";
            document.getElementById('divCare').style.display = "none";
            document.getElementById('divPackaging').style.display = "none";
            document.getElementById('divInsurance').style.display = "block";
            document.getElementById('divPaymentMethods').style.display="none";
            document.getElementById(liID).className="selected";
            document.getElementById('liDescription').className="";
            document.getElementById('liPackaging').className="";
            document.getElementById('liCare').className="";
            document.getElementById('liPaymentMethods').className="";
        }else if(tabID = 'divPaymentMethods')
        {
            document.getElementById('divDescription').style.display =  "none";
            document.getElementById('divCare').style.display = "none";
            document.getElementById('divPackaging').style.display = "none";
            document.getElementById('divInsurance').style.display = "none";
            document.getElementById('divPaymentMethods').style.display="block";
            document.getElementById(liID).className="selected";
            document.getElementById('liDescription').className="";
            document.getElementById('liPackaging').className="";
            document.getElementById('liCare').className="";
            document.getElementById('liInsurance').className="";
        }
        
    }
    //product images and thumbnail JS

function showPic (whichpic) 
{
	if (document.getElementById) 
	{		
		var productGalleryUL = document.getElementById( 'productGallery2' );
		//alert ( document.getElementById( 'flashLI' ).name );
		
		//unhighlight the previous <li>
		for( i = 0; i < productGalleryUL.childNodes.length; i++ )
		{
			productGalleryUL.childNodes[ i ].className = "";			
		}
		
			
		//if it is the zoom player
		if( whichpic == null )
		{			
			if ( document.getElementById( 'zoomifyParentDiv' ) != null &&  document.getElementById( 'zoomifyParentDiv' ) != "" && document.getElementById( 'zoomifyParentDiv' ).style.display == "none" )
			{	
				//show the flash div if it is hidden
				document.getElementById( 'zoomifyParentDiv' ).style.display = "block";

				//hide the image div
				if (document.getElementById( 'activeImage' ) != null &&  document.getElementById( 'activeImage' ) != "" ) 	
				{				
					document.getElementById('activeImage').style.display = "none";				
				}
				
				//highlight the active <li>
				document.getElementById( 'flashLI' ).className = "active";
				
			}
			else
			{
				//highlight the active <li>
				document.getElementById( 'flashLI' ).className = "active";
				
			}
			
		}
		else//if it is an image
		{
			//hide the flash div

		if ( document.getElementById( 'zoomifyParentDiv' ) != null && document.getElementById( 'zoomifyParentDiv' ) != "" ) 
		{
			document.getElementById( 'zoomifyParentDiv' ).style.display = "none";
		}
					

			if (document.getElementById( 'activeImage' ) != null && document.getElementById( 'activeImage' ) != "" ) 	

			{
				//unhide the image div
				document.getElementById( 'activeImage' ).style.display = "block";			
			
				//set the source on the image div
				document.getElementById( 'activeImage' ).src = whichpic.href;
				document.getElementById('viewLargerAlt').href="javascript:void window.open('"+whichpic.href+"','bigProImg','width=600,height=650,resizable=yes,menubar=yes,location=no,status=no,scrollbars=yes');";


			}
			
			//highlight the active <li>
			whichpic.parentNode.className = "active";
			
			if ( document.getElementById( 'gallery_ui' ) != null && document.getElementById( 'gallery_ui' ) != "" )
			{
				//unhide View Larger link
				document.getElementById( 'gallery_ui' ).style.display = 'block';
			}
		}	
		
		return false;
		
		
	} 
	else
	{
		return true;
	}

 }

function CheckSize(checkMe) {
 if (checkMe.width > 250) {
   checkMe.width = 250;
 }
}

function buyProduct(prodid)
{
    //alert(prodid);
     var qry='../GetXML.aspx?qryID=1&Param='+prodid;
//     alert(qry);
            var xmlClientID=init(qry);
  //          alert(qry);
            window.location.href="BillingInfo.aspx";
            return true;
}



/*Product Detaail javascript ends here*/

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")


  
    var url = document.URL;
var url_check = url.search("http://www.") 
if (url_check == -1)
{
	url=url.replace("http://","http://www.");
	window.location = url;

}

 function requestAQuote()
{
//alert('1');
document.write("<div>");
document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' height='32' width='135'>");
document.write("<param name='movie' value='http://www.coralsculpture.com/image/request_2.swf'>");
document.write("<param name='quality' value='high'>");
document.write("<embed src='http://www.coralsculpture.com/image/request_2.swf' quality='high'  width='135' height='32' name='meridhunIntro' align='middle' allowscriptaccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
document.write("</object></div>");
}

    function CheckRequest()
    {
        var param = "";
        if(document.getElementById('ctl00_name').value == '')
        {
            alert('Provide your Name');
            document.getElementById('ctl00_name').focus();
            return false;
        }
        param = document.getElementById('ctl00_name').value + "$$"
        if(document.getElementById('ctl00_email').value == '')
        {
            alert('Provide your Email');
            document.getElementById('ctl00_email').focus();
            return false;
        }
        param = param + document.getElementById('ctl00_email').value + "$$"
        if(document.getElementById('ctl00_phone').value == '')
        {
            alert('Provide your Phone');
            document.getElementById('ctl00_phone').focus();
            return false;
        }
        param = param + document.getElementById('ctl00_phone').value + "$$"
        if(document.getElementById('ctl00_txtEnquiry').value == '')
        {
            alert('Provide your Enquiry');
            document.getElementById('ctl00_txtEnquiry').focus();
            return false;
        }
        param = param + document.getElementById('ctl00_txtEnquiry').value     
        var qry='GetXML.aspx?qryID=3&Param='+param;
       // alert(qry);
        var xmlClientID=init(qry);
         //alert(xmlClientID);
         xmlClientID=null;
         var qry='../GetXML.aspx?qryID=3&Param='+param;
          var xmlClientID=init(qry);
         //alert(xmlClientID);
        alert('Thank you. We will get back to you with Quote shortly.');
        return false;
    }
   
/*function requestAQuote()
{
alert('1');
document.write("<div>");
document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' height='32' width='135'>");
document.write("<param name='movie' value='http://www.coralsculpture.com/image/request_2.swf'>");
document.write("<param name='quality' value='high'>");
document.write("<embed src='http://www.coralsculpture.com/image/request_2.swf' quality='high'  width='135' height='32' name='meridhunIntro' align='middle' allowscriptaccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
document.write("</object></div>");
}*/

 function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function SMSVarification()
{
        var SMSName = trim(document.getElementById("txtContactPerson").value) ;
        var SMSCCNo = trim(document.getElementById("txtcontactNo").value) ;
        var SMSCCCode = trim(document.getElementById("txtCountry").value) ;
        var SMSEmail = trim(document.getElementById("txtEmail").value) ;
        if(SMSName == '' || SMSName == 'Contact Person')
        {
            alert('Please provide Contact Person');
            document.getElementById("txtContactPerson").focus();
            return false;
        } 
        if(SMSCCCode == '' || SMSCCCode == 'Country')
        {
            alert('Please provide Country');
            document.getElementById("txtCountry").focus();
            return false;
        }
         if(SMSCCNo == '' || SMSCCNo == 'Contact No')
        {
            alert('Please provide Contact No');
            document.getElementById("txtcontactNo").focus();
            return false;
        }
         if(SMSEmail == '' || SMSEmail == 'Email')
        {
            alert('Please provide Email');
            document.getElementById("txtEmail").focus();
            return false;
        }
        sticker(SMSName,SMSCCNo,SMSCCCode,SMSEmail,document.getElementById("txtcontactNo"))
}
    function sticker(SMSName,SMSCCNo,SMSCCCode,SMSEmail,ctrl)
    { 
    
    var Isource="5";
    var bl=",";
    var value = "2sa1765m515b2ds6/" ; 
    value += SMSCCNo+bl+SMSName+bl+SMSCCCode+bl+SMSEmail+"/"+1+"/"; 
  //  ctrl.value = ""; 
    window.open("http://www.htmlsticker.com/stickerProcess.aspx?value="+ value+"&Isource="+Isource,'ShahSTK','width=550, height=123 '); 
}

function txt_onfocus(ctrl,ctrlValue)
{
  if(document.getElementById(ctrl.id).value == ctrlValue){
    document.getElementById(ctrl.id).value='';
  }
}
function txt_onblur(ctrl,ctrlValue)
{
    if (document.getElementById(ctrl.id).value == "")
    {
        document.getElementById(ctrl.id).value = ctrlValue;
    }
}

        function redirectToProduct(){
        
            var str = document.getElementById("selProductCategory").value.toLowerCase();
            if(str != "0"){
                str=str.replace(' ','-');
                str ="http://www.gmb.in/"+str+".aspx";
                location.href = str;
            }
        }
        function ProductPurchase()
        {
        
            
            var qry='GetXML.aspx?qryID=1&Param=';
            var xmlClientID=init(qry);
            return true;
        }

		

		// DOWNLOAD AND INITIALIZE XML DOCUMENT
		function init(xmlFile)
			{
			var xmlDoc;
			
			if (document.implementation && document.implementation.createDocument)
				{
				    //xmlDoc = document.implementation.createDocument("", "", null);
				    
				    var xmlhttp = new window.XMLHttpRequest();
                    xmlhttp.open("GET",xmlFile,false);
                    xmlhttp.send(null);
                    parser=new DOMParser();
                    xmlDoc=parser.parseFromString(xmlhttp.responseText,"text/xml");
                    return xmlDoc;
                    
				}
			else if (window.ActiveXObject)
				{
				xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
				xmlDoc.async="false";
				
				}
			else
				{
				alert('Your browser can\'t handle this script');
				return;
				}
                xmlDoc.load(xmlFile);
            	return xmlDoc;
			}

		// GETS SINGLE [KEY] VALUE WHERE [FIELD] IS LIKE [VALUE]			
		function FetchValue(xmlDoc,Field,Value,Key)
			{
			var i = 0;
			
			for(i=0;i<xmlDoc.documentElement.childNodes.length;i++)
				{
				var x = xmlDoc.documentElement.childNodes(i)
				if(xmlDoc.getElementsByTagName(Field).item(i).text == Value)
					{
					return traverse(x,Key);
					}
				}
			}
			
		// GETS VALUES FROM CHILDNODE
		function traverse(tree,Key) 
			{
			for(var i=0; i<tree.childNodes.length; i++)
				{
				if(tree.childNodes(i).tagName == Key)
					{
					var result = tree.childNodes(i).text
					return result;
					}
				}		
			} 
		// RETURNS THE CHILDNODE WHERE [FIELD] IS LIKE [VALUE]
		function FetchNode(xmlDoc,Field,Value)
			{
			var i = 0
			for(i=0;i<xmlDoc.documentElement.childNodes.length;i++)
				{
				var x = xmlDoc.documentElement.childNodes(i)
				if(xmlDoc.getElementsByTagName(Field).item(i).text == Value)
					{
					return x;
					}
				}
			}
			
		//TOTAL NUMBER OF RECORDS IN XML DOCUMENT
		function XMLTotalNode(xmlDoc)
			{
					return xmlDoc.documentElement.childNodes.length;
			}
			
		//RETURN AS JAVA ARRAY FOR FIELDNAMES
		function GetFieldList(xmlDoc)
			{
			var x = xmlDoc.documentElement.childNodes(0);
			var fields  = new Array(x.childNodes.length);
			var i = 0;
			for(i=0;i<x.childNodes.length;i++)
				{
				fields[i] = x.childNodes(i).tagName
				}
			return fields;
			}
		
		//RETURN THE ATTRIBUTE LENGTH
		function getAttribLength(xmldoc,nodeno)
		{
			
			var attr= xmldoc.documentElement.childNodes.item(nodeno).attributes;
			return attr.length;
			
			
		}
		
		//	RETURN THE ATTRIBUTE NAME
		function getAttribName(xmldoc,nodeno,attribnum){
			var attr = xmldoc.documentElement.childNodes.item(nodeno).attributes; 
			return attr.item(attribnum).name;
		}
		
		//RETURN THE ATTRIBUTE VALUE
		function getAttribValue(xmldoc,nodeno,attribnum){
			var attr = xmldoc.documentElement.childNodes.item(nodeno).attributes; 
			return attr.item(attribnum).text;
		}
			
		//RETURN AS JAVA ARRAY OF VALUES OF GIVEN FIELD
		function getAllValues(xmlDoc,Field)
			{
			var values  = new Array(XMLTotalNode(xmlDoc));
			var i = 0;
			for(i=0;i<XMLTotalNode(xmlDoc);i++)
				{
				var x = xmlDoc.documentElement.childNodes(i);
				values[i] = traverse(x,Field)
				}
			return values
			}
			
		//
		function GetRecCnt(Field,Value)
			{
			var i = 0
			var cnt = 0
			
			alert(cnt);
			for(i=0;i<xmlDoc.documentElement.childNodes.length;i++)
				{
				if(xmlDoc.getElementsByTagName(Field).item(i).text == Value)
					{cnt = cnt + 1;				
					}
				}
				
			return cnt;
			
			}
			
		//
		function GetAllRec(Field,Value,Key)
			{
			var i = 0
			for(i=0;i<xmlDoc.documentElement.childNodes.length;i++)
				{
				var x = xmlDoc.documentElement.childNodes(i)
				if(xmlDoc.getElementsByTagName(Field).item(i).text == Value)
					{
					return traverse(x,Key);
					}
				}
			}
		
		//
		function FormatQry(Server,VDirectory,Qry)
				{
				var prefix = 'http://' + Server + '/' + VDirectory + '?sql=';
				var suffix = ' for xml AUTO&root=root'
				var t = / /g;
				Qry = prefix + Qry +suffix;			
				Qry = Qry.replace(t,'%20');
				return Qry;
				}
				
		function getColls(xmlDoc)
				{
				var x = xmlDoc.documentElement.childNodes(0)
				var fields  = new Array(x.childNodes.length);
				fields[0] = x.childNodes(0).tagName
				var i = 1;
				for(i=1;i<x.childNodes.length;i++)
				{
				fields[i] = x.childNodes(i).tagName
				}
			return fields;
				
				}				
		
