// JavaScript Document

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->


function call_autocomplete()
{
var tmp=document.getElementsByTagName("form");
for(i=0;i<tmp.length;i++)
tmp[i].setAttribute('autocomplete',"off");
}

//<![CDATA[
		function startCallback() { 
		
		document.getElementById('light').style.display='block';
		document.getElementById('fade').style.display='block'
		
		document.getElementById('light').innerHTML ="<img src='images/loading.gif' alt=''/>";
			// make something useful before submit (onStart)
			return true;
		}

		function completeCallback(response) { 
		if(response!="")
		document.getElementById('light').innerHTML = "<span style='margin:0px; padding:0px 0px 0px 0px; font-family:Arial, Helvetica, sans-serif; font-size:22px; text-align:center; color:#FFFFFF; font-weight:bold; '>Error:Mail was not sent.</span>";
		else
		document.getElementById('light').innerHTML = "<span style='margin:0px; padding:0px 0px 0px 0px; font-family:Arial, Helvetica, sans-serif; font-size:22px; text-align:center; color:#FFFFFF; font-weight:bold; '>Thank You. We got your order.</span>";
		setTimeout("callover()",5000);			
		
		}
		function callover()
		{
		document.getElementById('light').style.display='none';
		document.getElementById('fade').style.display='none' 
		
		document.qcbossfrm.reset();
		/*document.qcbossfrm.txtName.value="";
		document.qcbossfrm.txtEmail.value="";
		document.qcbossfrm.txtPhone.value="";
		document.qcbossfrm.txtOthers.value="";
		document.qcbossfrm.txtLink.value="";
		document.qcbossfrm.file.value="";
		document.qcbossfrm.fdisplay.value=""; */
		//document.getElementById('vdisplay').style.display="none";
		
		}
		
	
	/* Smooth scrolling
   Changes links that link to other parts of this page to scroll
   smoothly to those links rather than jump to them directly, which
   can be a little disorienting.

   sil, http://www.kryogenix.org/

   v1.0 2003-11-11
   v1.1 2005-06-16 wrap it up in an object
*/

var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
	var als =0;
	als = allLinks.length;
    for (var i=0;i<als;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {

    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeType == 3 || target.nodeName.toLowerCase()=='img') {
      target = target.parentNode;
    }

    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;

    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var allDivs = document.getElementsByTagName('div');
    var all = [allLinks, allDivs];
    var destinationLink = null;
    for (var j=0; j<all.length; j++) {
      for (var i=0;i<all[j].length;i++) {
        var lnk = all[j][i];
        if (lnk.name && (lnk.name == anchor)) {
          destinationLink = lnk;
          break;
        } else if (lnk.id && (lnk.id == anchor)){
	  destinationLink = lnk;
          break;
	}
      }
    }
    /*
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    */

    // If we didn't find a destination, give up and let the browser do
    // its thing

    if (!destinationLink) return true;

    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
	
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }

    // Stop any current scrolling
    clearInterval(ss.INTERVAL);

    cypos = ss.getCurrentYPos();

    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
	
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',17);

    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
	
    if ( (wascypos == iscypos) || isAbove != isAboveNow) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 50;

ss.addEvent(window,"load",ss.fixAllLinks);
//]]>


//<![CDATA[
function trimSpace(x)
{
	var emptySpace = / /g;
	var trimAfter = x.replace(emptySpace,"");
	return(trimAfter);
}
function textValidate(incomingString)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/[^a-zA-Z ]/g) != -1)
		return false;
	else
		return true;
}
function phoneValidate(incomingString)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/[^0-9 \+\-]/g) != -1)
		{
		 return false;
		}
	else
		return true;
}
function limitlength(obj, length)
{
	var maxlength=length;
	if (obj.value.length>maxlength)
		obj.value=obj.value.substring(0, maxlength);
}
function enter_check(e)
{
		var whichCode = (window.Event) ? e.which : e.keyCode;

		if (whichCode == 8 || whichCode == 0)
		{
			return true;
		}
	if (whichCode == 13)
		{		
			
			return false;
		}
}

//Clear condents...
function clr()
{
	document.qcbossfrm.reset();
	return false;
}

function validate()
{

if(trimSpace(document.qcbossfrm.txtName.value)=="")
	{
		alert("Please enter your name")
		document.qcbossfrm.txtName.focus()
		document.qcbossfrm.txtName.select()
		return false
	}	
if(!textValidate(document.qcbossfrm.txtName.value))
	{
		alert("Please enter your name (Alphabets only)")
		document.qcbossfrm.txtName.focus()
		document.qcbossfrm.txtName.select()
		return false
	}
var emailexp = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9\-]+)\.(([a-zA-Z]{2,}|[0-9]{2,})|([a-zA-Z]{2,}\.[a-zA-Z]{2,})|([a-zA-Z]{2,}\.[a-zA-Z]{2,}\.[a-zA-Z]{2,}))$/;
	if(trimSpace(document.qcbossfrm.txtEmail.value)=="")
	{
		alert("Please enter your e-mail id")
		document.qcbossfrm.txtEmail.focus()
		document.qcbossfrm.txtEmail.select()
		return false
    }
	if(!emailexp.test(document.qcbossfrm.txtEmail.value))
	{
		alert("Please enter valid e-mail id")
		document.qcbossfrm.txtEmail.focus()
		document.qcbossfrm.txtEmail.select()
		return false
    }
	if(trimSpace(document.qcbossfrm.txtPhone.value)!="")
	{
	
		var str=document.qcbossfrm.txtPhone.value;
		if(str.indexOf("%")!=-1 || str.indexOf("<")!=-1 || str.indexOf(">")!=-1|| str.indexOf("\\")!=-1|| str.indexOf("/")!=-1|| str.indexOf("\'")!=-1|| str.indexOf("{")!=-1 || str.indexOf("}")!=-1|| str.indexOf("[")!=-1|| str.indexOf("]")!=-1|| str.indexOf("(")!=-1|| str.indexOf(")")!=-1 || str.indexOf("*")!=-1|| str.indexOf("!")!=-1|| str.indexOf("#")!=-1)
		{	
		alert("Please enter valid phone number");
		document.qcbossfrm.txtPhone.focus()
		document.qcbossfrm.txtPhone.select()
		return false	
		}
		
	if(!phoneValidate(document.qcbossfrm.txtPhone.value))
	{
		alert("Please enter valid phone number");
		document.qcbossfrm.txtPhone.focus()
		document.qcbossfrm.txtPhone.select()
		return false
	}
	if(document.qcbossfrm.txtPhone.value==0)
	{
		alert("Please enter valid phone number");
		document.qcbossfrm.txtPhone.focus()
		document.qcbossfrm.txtPhone.select()
		return false
	}
	if(document.qcbossfrm.txtPhone.value.charAt(1)=='\+'||document.qcbossfrm.txtPhone.value.charAt(1)=='\-')
	{
		alert("Please enter valid phone number");
		document.qcbossfrm.txtPhone.focus()
		document.qcbossfrm.txtPhone.select()
		return false
	}
	
	}
	
	
	if(trimSpace(document.qcbossfrm.file.value)=="" && trimSpace(document.qcbossfrm.txtLink.value)=="")
	{
	
		alert("Please upload file or link");
		document.qcbossfrm.txtLink.focus();		
		return false					
	}
	if(trimSpace(document.qcbossfrm.file.value)!="")
	{
		var filenam=document.qcbossfrm.file.value;
		str=new String(filenam)
		var s=str.indexOf(".");
		if(s!=-1)
		{
			var offer=str.substring(s+1);
			var offer1=offer.indexOf("exe");
			if(offer1!=-1)
			{
				alert("Please upload valid file or link");
				document.qcbossfrm.txtLink.focus();
				return false;
			}
		}
	}
	
	if(document.qcbossfrm.txtLink.value!="")
	{
	
	var str2=document.qcbossfrm.txtLink.value;
	if( str2.indexOf("<")!=-1 || str2.indexOf(">")!=-1|| str2.indexOf("\'")!=-1|| str2.indexOf("{")!=-1 || str2.indexOf("}")!=-1|| str2.indexOf("[")!=-1|| str2.indexOf("]")!=-1|| str2.indexOf("(")!=-1|| str2.indexOf(")")!=-1 || str2.indexOf("*")!=-1|| str2.indexOf("!")!=-1|| str2.indexOf("#")!=-1)
	{
	alert("Please upload valid file or link");
	document.qcbossfrm.txtLink.focus();
	document.qcbossfrm.txtLink.select();
	return false
	}
	}
		
	if(trimSpace(document.qcbossfrm.txtOthers.value)!="")
	{
	var str1=document.qcbossfrm.txtOthers.value;
	
	if(str1.indexOf("*")!=-1|| str1.indexOf("'")!=-1)
	{
		alert("Please do not use special characters (such as * and ' )");
		document.qcbossfrm.txtOthers.focus();
		document.qcbossfrm.txtOthers.select();
		return false
	}
	}
return true;
}

function callfdisp()
{ 

var str1 = document.qcbossfrm.file.value;
document.qcbossfrm.fdisplay.value = str1.slice(str1.lastIndexOf("\\")+1);
}
//]]>



//<![CDATA[
/******************************************
* Snow Effect Script- By Altan d.o.o. (http://www.altan.hr/snow/index.html)
* Visit Dynamic Drive DHTML code library (http://www.dynamicdrive.com/) for full source code
* Last updated Nov 9th, 05' by DD. This notice must stay intact for use
******************************************/
 /*
  //Configure below to change URL path to the snow image
  var snowsrc="images/snow.gif"
  // Configure below to change number of snow to render
  var no = 200;
  // Configure whether snow should disappear after x seconds (0=never):
  var hidesnowtime = 100;
  // Configure how much snow should drop down before fading ("windowheight" or "pageheight")
  var snowdistance = "windowheight";

///////////Stop Config//////////////////////////////////

  var ie4up = (document.all) ? 1 : 0;
  var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

	function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 200, doc_height = 100; 
  
  if (ns6up) {
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
  } else if (ie4up) {
    doc_width = iecompattest().clientWidth;
    doc_height = iecompattest().clientHeight;
  }

  dx = new Array();
  xp = new Array();
  yp = new Array();
  am = new Array();
  stx = new Array();
  sty = new Array();
  snowsrc=(snowsrc.indexOf("xerago.com")!=-1)? "images/snow.gif" : snowsrc
  for (i = 0; i < no; ++ i) {  
    dx[i] = 0;                        // set coordinate variables
    xp[i] = Math.random()*(doc_width-50);  // set position variables
    yp[i] = Math.random()*doc_height;
    am[i] = Math.random()*25;         // set amplitude variables
    stx[i] = 0.07 + Math.random()/10; // set step variables
    sty[i] = 5.7 + Math.random();     // set step variables
		if (ie4up||ns6up) {
      if (i == 0) {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://xerago.com\"><img src='"+snowsrc+"' border=\"0\"><\/a><\/div>");
      } else {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"><\/div>");
      }
    }
  }

  function snowIE_NS6() {  // IE and NS6 main animation function
    doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
		doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")?  iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
    for (i = 0; i < no; ++ i) {  // iterate for every dot
      yp[i] += sty[i];
      if (yp[i] > doc_height-50) {
        xp[i] = Math.random()*(doc_width-am[i]-30);
        yp[i] = 0;
        stx[i] = 0.02 + Math.random()/10;
        sty[i] = 1.0 + Math.random();
      }
      dx[i] += stx[i];
      document.getElementById("dot"+i).style.top=yp[i]+"px";
      document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";  
    }
    snowtimer=setTimeout("snowIE_NS6()", 10);
  }

	function hidesnow(){
		if (window.snowtimer) clearTimeout(snowtimer)
		for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
	}
		

if (ie4up||ns6up){
    snowIE_NS6();
		if (hidesnowtime>0)
		setTimeout("hidesnow()", hidesnowtime*100000)
		}
*/
//]]>
