/*
{NY notes}

Guys I m  using this for cross browser usablity and to make http calls more reliable. --ny
Please follow the comments..
*/
function yconnect(url,frm,cnt)
{
   
//show the result in this content
    var responseSuccess = function(o){ 
 //alert(url);
         if(cnt=='cal_div'){
		txt=o.responseText;

		var mydata=new Array();
		var myfinaldata=new Array();
		mydata=txt.split("<!--CALENDAR STARTS HERE-->");
		 myfinaldata=mydata[1].split("<!--CALENDAR ENDS HERE-->");
		// alert(myfinaldata[1]);
		 myeventdata=myfinaldata[1].split("<!--EVENT STARTS HERE-->");
		 myfinaleventdata=myeventdata[1].split("<!--EVENT ENDS HERE-->");
		 
		 //alert(myfinaleventdata[0]);
		// alert(myfinaldata[0]);
		 document.getElementById(cnt).innerHTML=myfinaldata[0];
		 document.getElementById('cal_event').innerHTML=myfinaleventdata[0];
		 //alert('here');
		 }
		 else{
		document.getElementById(cnt).innerHTML=o.responseText;
                if(cnt=='newsletter')
                {parsejs(o.responseText);}
		 }
		
    }

//if any failure show msg 
    var responseFailure = function(o){ 
        alert("XMLHTTPRequest Failure");
    }

//used to handle call back events     
    var callback =
    {
        success:responseSuccess,
        failure:responseFailure
    }



// Create object and intiate connection. 	

	if(frm != ''){
		// set the from where you need to get the data 
		YAHOO.util.Connect.setForm(frm);
		var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback,null);
	}else{
		var cObj = YAHOO.util.Connect.asyncRequest('GET', url, callback,null);
	}




//This is to check the connection status 
	var callStatus = YAHOO.util.Connect.isCallInProgress(cObj);

// check for the status and show loading information 

if(!(cnt.match("add_basket") || cnt.match("newsletter")))
{
	if(callStatus){
		document.getElementById(cnt).innerHTML="<span style='color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:10px;'><img src='images/progress.gif' align='absmiddle' border='0'></span>";
	}
}
}	

var parsedjstxt;
function parsejs(txt)
{
var temp1=txt.match(/<Script[\s\r\t]*language=[\"|\']javascript[\"|\'][\s\r\t]*src="?'?([^<\"\'>]*)"?'?\>([^<>]*)<\/script\>/i);
if(temp1)
{
  var elem=document.createElement('script');
  elem.src=temp1[1];
  document.body.appendChild(elem);
  var text=txt.replace(/<Script[\s\r\t]*language=[\"|\']javascript[\"|\'][\s\r\t]*src="?'?([^<\"\'>]*)"?'?\>([^<>]*)<\/script\>/i,'');
  txt=text;
}
 var temp=txt.match(/<Script[^<>]*>([^<>]*)<\/script>/i);
if(temp)
 { 
  parsedjstxt+=temp[1];
  var text=txt.replace(/<script[^<>]*>([^<>]*)<\/script>/i,'');
  parsejs(text);
 }
 else
 {
  setTimeout('eval(parsedjstxt)',100);
 }
 
}
