function getXMLObject()  //XML OBJECT

{

   var xmlHttp = false;

   try 

   {

     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers

   }

   catch (e) 

   {

     try 

	 {

       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+

     }

     catch (e2)

	 {

       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false

     }

   }

   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') 

   {

     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers

   }

   return xmlHttp;  // Mandatory Statement returning the ajax object created

}

function getXMLObject1()
{
	xmlHttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Opera, etc.
  xmlHttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
}

 

var xmlhttp = new getXMLObject();	//xmlhttp holds the ajax object





function getSessionVariables()

{

  var getdate = new Date();  //Used to prevent caching during ajax call


	var xmlhttp = new getXMLObject();	
  if(xmlhttp != null) 

  { 
	//xmlhttp.retValue = '';
    xmlhttp.open("POST","getSessionVariables.php",false); //calling getSessionVariables.php using POST method

    xmlhttp.onreadystatechange  = handleServerResponse;

    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

    xmlhttp.send("vrb=cid"); //Posting txtname to PHP File

  }

}



function handleServerResponse() 

{

	if (xmlhttp.readyState == 4) 

	{

		if(xmlhttp.status == 200) 

		{

			//document.getElementById("message").innerHTML=xmlhttp.responseText; //Update the HTML Form element 

			xmlhttp.retValue  = xmlhttp.responseText;

			//alert(xmlhttp.responseText);



		}

		else

		if (xmlhttp.status==404) 

			alert("URL doesn't exist!")

		else

			alert("Error during AJAX call. Status is "+xmlhttp.status)



	}

}



function checkQuantity()

{

	var submitForm = false;

	//check quantity

	if(document.getElementById('quantity1').value > 0)

	{

		//check payment type

		var paymentTypeArr = -1;

		for(var i=0; i < document.getElementsByName('payingBy').length; i++)

		{

			

			if(document.getElementsByName('payingBy')[i].checked)

			{

				paymentTypeVal = document.getElementsByName('payingBy')[i].value;

				//changes

				paymentTypeArr = i;

			}

		}

		

	

		//check artworks

		var artworkArr=-1;

		for(var i=0; i < document.getElementsByName('artworks').length; i++)

		{

			

			if(document.getElementsByName('artworks')[i].checked)

			{

				artworkVal = document.getElementsByName('artworks')[i].value;

				//changes

				artworkArr = i;

			}

		}

			

		if(artworkArr > -1)

		{


			if(paymentTypeArr > -1)

				submitForm = true;

			else

			{

				tooltip.show('&nbsp;&nbsp;Please select Payment Type.', 250);

				setTimeout("tooltip.hide()", 4000);

			}

		}

		else

		{

			tooltip.show('&nbsp;&nbsp;Please select Artwork.', 250);

			setTimeout("tooltip.hide()", 4000);

		}

		

	}

	else

	{	

		tooltip.show('&nbsp;&nbsp;&nbsp;Quantity is zero.', 150);

		setTimeout("tooltip.hide()", 4000);

		

	}

	

	

	if(submitForm)

	{

		document.forms['orderForm'].submit();

	}

}



var bar = 7;



function findPosX(obj)

{

	

	var curleft = 0;

	if(obj.offsetParent)

	{

		while(1) 

		{

		  curleft += obj.offsetLeft;

		  if(!obj.offsetParent)

			break;

		  obj = obj.offsetParent;

		}

	}

	else 

	if(obj.x)

	{

		curleft += obj.x;

	}

	

	return curleft;

	

}





function findPosY(obj)

{

	var curtop = 0;

	if(obj.offsetParent)

		while(1)

		{

		  curtop += obj.offsetTop;

		  if(!obj.offsetParent)

			break;

		  obj = obj.offsetParent;

		}

	else if(obj.y)

		curtop += obj.y;

	return curtop;

}





var tooltip=function(){

var id = 'tt';



 var top = 3;

 var left = 3;

 //alert(asd);

 //var top = parseInt(findPosY(document.getElementById("qprice"))+"");

 //var left = parseInt(findPosX(document.getElementById("qprice"))+"");



 

 var maxw = 1000;

 var speed = 10;

 var timer = 40;

 var endalpha = 95;

 var alpha = 0;

 var tt,t,c,b,h;

 var ie = document.all ? true : false;

 return{

  show:function(v,w){

   if(tt == null){

    tt = document.createElement('div');

    tt.setAttribute('id',id);

    t = document.createElement('div');

    t.setAttribute('id',id + 'top');

    c = document.createElement('div');

    c.setAttribute('id',id + 'cont');

	

    b = document.createElement('div');

    b.setAttribute('id',id + 'bot');

    tt.appendChild(t);

    tt.appendChild(c);

    tt.appendChild(b);

	tt.style.position = "absolute";

	tt.style.left = findPosX(document.getElementById("quantity1"));

	tt.style.top = findPosY(document.getElementById("quantity1"));

	//tt.style.backgroundColor = "red";	

	tt.style.fontFamily = 'Arial, Helvetica, sans-serif';

	tt.style.fontSise = '13px';

	tt.style.fontWeight = 'bold';

	//tt.style.color = '#44C2F4';

	tt.style.color = 'red';

	

	

	

    document.body.appendChild(tt);

    tt.style.opacity = 0;

    tt.style.filter = 'alpha(opacity=0)';

    document.onmousemove = this.pos;

   }

   tt.style.display = 'block';

   c.innerHTML = v;

   tt.style.width = w ? w + 'px' : 'auto';

   if(!w && ie){

    t.style.display = 'none';

    b.style.display = 'none';

    tt.style.width = tt.offsetWidth;

    t.style.display = 'block';

    b.style.display = 'block';

   }

  if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}

  h = parseInt(tt.offsetHeight) + top;

  clearInterval(tt.timer);

  tt.timer = setInterval(function(){tooltip.fade(1)},timer);

  },

  

  pos:function(e){

  

//   var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;

//   var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;

//   tt.style.top = (u - h) + 'px';

//   tt.style.left = (l + left) + 'px';

  

   	var x = findPosX(document.getElementById("quantity1"));

   	var y = findPosY(document.getElementById("quantity1"));

	

    tt.style.top = y-25  + 'px';

	tt.style.left = x+300 + 'px';

  },

  

  fade:function(d){

   var a = alpha;

   if((a != endalpha && d == 1) || (a != 0 && d == -1)){

    var i = speed;

   if(endalpha - a < speed && d == 1){

    i = endalpha - a;

   }else if(alpha < speed && d == -1){

     i = a;

   }

   alpha = a + (i * d);

   tt.style.opacity = alpha * .01;

   tt.style.filter = 'alpha(opacity=' + alpha + ')';

  }else{

    clearInterval(tt.timer);

     if(d == -1){tt.style.display = 'none'}

  }

 },

 hide:function(){

  clearInterval(tt.timer);

   tt.timer = setInterval(function(){tooltip.fade(-1)},timer);

  }

 };

}();




