var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

var collectiontoolTipSTYLE="";
var collectioncontent = "";
function initToolTipsCollection()
{
  if(ns4||ns6||ie4)
  {
    if(ns4) collectiontoolTipSTYLE = document.collectiontoolTipLayer;
    else if(ns6) collectiontoolTipSTYLE = document.getElementById("collectiontoolTipLayer").style;
    else if(ie4) collectiontoolTipSTYLE = document.all.collectiontoolTipLayer.style;
	

    if(ns4) document.captureEvents(Event.MOUSEMOVE);
    else
    {
      collectiontoolTipSTYLE.visibility = "visible";
      collectiontoolTipSTYLE.display = "";
//	  collectiontoolTipSTYLE.left = ((((screen.availWidth)-800)/2)+170) + 'px' ;
	  collectiontoolTipSTYLE.left = ((((screen.availWidth)-430)/2)-33) + 'px' ;
	  collectiontoolTipSTYLE.top = '131px';
    }
  }
}

function CollectiontoolTip(msg, fg, bg)
{
  if(CollectiontoolTip.arguments.length < 1) // hide
  {
    if(ns4) collectiontoolTipSTYLE.visibility = "hidden";
    else collectiontoolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!fg) fg = "#777777";
    if(!bg) bg = "#FFFFFF";

	//collectioncontent 
    //var collectioncontent = msg ;
	
	document.getElementById("collectiontoolTipLayer").innerHTML = collectioncontent;
	document.getElementById("collectiontoolTipLayer").style.display = "";

    if(ns4)
    {
      collectiontoolTipSTYLE.document.write(collectioncontent);
      collectiontoolTipSTYLE.document.close();
      collectiontoolTipSTYLE.visibility = "visible";
    }

    if(ns6)
    {	  
      document.getElementById("collectiontoolTipLayer").innerHTML = collectioncontent;
      collectiontoolTipSTYLE.display='block'
    }
    if(ie4)
    {
     document.all("collectiontoolTipLayer").innerHTML=collectioncontent;
      collectiontoolTipSTYLE.display='block'
    }
  }
}

function testpage(visibeltime)
{
	//alert("this is test page ...?");

collectioncontent = '<table id="Table_01" width="400" height="201" border="0" cellpadding="0" cellspacing="0">';
collectioncontent = collectioncontent +	'<tr><td colspan="7"><img src="collectionimages/banner_01.gif" width="400" height="3" alt=""></td></tr>';
collectioncontent = collectioncontent +	'<tr><td colspan="5"><img src="collectionimages/banner_02.gif" width="383" height="10" alt=""></td><td><a onclick="javascript:closepopup();" style="cursor:hand"><img src="collectionimages/banner_03.gif" width="12" height="10" alt=""></a></td><td><img src="collectionimages/banner_04.gif" width="5" height="10" alt=""></td></tr>';
collectioncontent = collectioncontent +	'<tr><td colspan="7"><img src="collectionimages/banner_05.gif" width="400" height="142" alt=""></td></tr>';
collectioncontent = collectioncontent +	'<tr><td><img src="collectionimages/banner_06.gif" width="18" height="14" alt=""></td><td style="background-color:#595959"><input type="text" name="ClsCustomer_user_name" style="width:97px;border:0px;height:10px;border-width:1px;font-family:Verdana;font-size:9px;" maxlength="50" class="registertextbox"></td><td><img src="collectionimages/banner_08.gif" width="5" height="14" alt=""></td><td><a onclick="javascript:CheckFormField();" style="text-decoration:none;cursor:hand;"><img src="collectionimages/banner_09.gif" width="58" height="14" alt=""></a></td><td colspan="3"><img src="collectionimages/banner_10.gif" width="220" height="14" alt=""></td></tr>';
collectioncontent = collectioncontent +	'<tr><td colspan="7"><img src="collectionimages/banner_11.gif" width="400" height="31" alt=""></td></tr>';
collectioncontent = collectioncontent +	'<tr><td><img src="collectionimages/spacer.gif" width="18" height="1" alt=""></td><td><img src="collectionimages/spacer.gif" width="99" height="1" alt=""></td><td><img src="collectionimages/spacer.gif" width="5" height="1" alt=""></td><td><img src="collectionimages/spacer.gif" width="58" height="1" alt=""></td><td><img src="collectionimages/spacer.gif" width="203" height="1" alt=""></td><td><img src="collectionimages/spacer.gif" width="12" height="1" alt=""></td><td><img src="collectionimages/spacer.gif" width="5" height="1" alt=""></td></tr>';
collectioncontent = collectioncontent +	'</table>';

if(visibeltime > 0)
		setTimeout('CollectiontoolTip()', visibeltime);
	setTimeout('CollectiontoolTip(0)',10);
}

function CheckFormField()
{
	var valid = 0;

	if(document.formmain.ClsCustomer_user_name.value == "")
	{
		alert('Please Enter Email Id');
		valid++;
	}
	else if(!isValidEmail(document.formmain.ClsCustomer_user_name.value))
	{	
			alert("Please Enter Valid Email");
			valid++;
	}

	if(valid==0)
	{ 
		document.formmain.ClsCustomer_hdnaction.value = "COLS";
		document.formmain.ClsCustomer_hdnsubmitted.value = "1";		
		document.formmain.submit();
	}
}

function closepopup()
{
	document.getElementById("Table_01").style.visibility="hidden";	
	ClosePopupAdvertise("advertisepopup.php","NO");
}

function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
	
	var a = email.indexOf("@");
	var b = email.indexOf(".") ;
	a = a + 1 ;

    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if(a == b) {
			return false;
	}
	else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function ClosePopupAdvertise(pagename,skip)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	var url=pagename;  
	url=url+"?skip_popup="+skip
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedPopup
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedPopup() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		document.getElementById("opttest").innerHTML=xmlHttp.responseText 
	 } 
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}