﻿function $(obj)
{
    return document.getElementById(obj);
}

window.onload=function onloaddiv()
{    
    if($("sendmsg_action").value=="123" || $("sendmsg_action").value=="456")
    {
        Concel();
    }
    else
    {
//        $("myshield__").style.width=document.body.offsetWidth;
//        $("myshield__").style.height=document.body.offsetHeight;
//        $("myshield__").style.display="block";
//        $("showDiv").style.display="block";
//        $("smalldiv").style.display="none";
        $("myshield__").style.display="none";
        $("showDiv").style.display="none";
        $("smalldiv").style.display="block";
    }
}

function getvalue()
{
    if($("objvalue").value=="1")
    {
        Concel();
    }
}

function Concel()
{
    $("myshield__").style.display="none";
    $("showDiv").style.display="none";
    $("smalldiv").style.display="block";
}

function Conver()
{
    
    $("smalldiv").style.display="none";
    
    $("myshield__").style.width=document.body.offsetWidth;
    $("myshield__").style.height=document.body.offsetHeight;
    function Z_Index2()
    {
        $("showDiv").style.display="block";
        $("myshield__").style.display="block";
    }
    Z_Index2();
}

function check(QQ)
{
    if(QQ.replace('<','').replace('>',"").length!=QQ.length){
        return false;
    }else
        return true;
}

function IsNumber(QQ)
{
    var Num="0123456789";
    for(i=0;i<QQ.length;i++)
    {       
      var c=QQ.charAt(i);
      if(Num.indexOf(c)==-1)
      {
  	     return false;
      }
    }
    return true;
}

function CheckInfo()
{
//    if($("sendmsg_details").value.length==226)
//    {
//        $("sendmsg_details").value="";
//        alert("please enter your buying details(min 20 chars)");
//        $("sendmsg_details").focus();
//        return false;
//    }
    if($("sendmsg_details").value.length<=20||$('sendmsg_details').getAttribute('gray') == '1')
    {
        $("sendmsg_details").focus();
        alert("please enter your buying details(min 20 chars)");
        return false;
    }
    if($("sendmsg_details").value.length>=3000)
    {
        alert("please enter your buying details(max 3000 chars)");
        $("sendmsg_details").focus();
        return false;
    }
    if($("sendmsg_subject").value!="")
    {
        if(!check($("sendmsg_subject").value))
        {
            alert("please enter valid subject");
            $("sendmsg_subject").select();
            return false;
        }
    }
    else
    {
        alert("please enter your subject");
        $("sendmsg_subject").focus();
        return false;
    }
    if($("sendmsg_keyword1").value==""&&$("sendmsg_keyword2").value==""&&$("sendmsg_keyword3").value=="")
    {
        alert("please enter your buy products(min one product)");
        $("sendmsg_keyword1").focus();
        return false;
    }
    if($("sendmsg_company").value=="")
    {
        alert("please enter your company name");
        $("sendmsg_company").focus();
        return false;
    }
    else
    {
        if(!check($("sendmsg_company").value))
        {
            alert("please enter valid company name");
            $("sendmsg_company").select();
            return false;
        }
    }
    if($("sendmsg_linkname").value=="")
    {
        alert("please enter your linkname");
        $("sendmsg_linkname").focus();
        return false;
    }
    else
    {
        if(!check($("sendmsg_linkname").value))
        {
            alert("please enter valid linkname");
            $("sendmsg_linkname").select();
            return false;
        }
    }
    var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
    if($("sendmsg_email").value!="")
    {
        if(pattern.test($("sendmsg_email").value))
        {  
            
        }
        else
        {
            alert("please enter valid email address");
            $("sendmsg_email").select();
            return false;
        }
    }
    else
    {
        alert("please enter valid email address");
        $("sendmsg_email").focus();
        return false;
    }
    if($("sendmsg_countrycode").value==""||!IsNumber($("sendmsg_countrycode").value))
    {
        alert("please enter valid country code");
        $("sendmsg_countrycode").focus();
        return false;
    }
    if($("sendmsg_placecode").value==""||!IsNumber($("sendmsg_placecode").value))
    {
        alert("please enter valid area code");
        $("sendmsg_placecode").focus();
        return false;
    }
    if($("sendmsg_phonecode").value==""||!IsNumber($("sendmsg_phonecode").value))
    {
        alert("please enter valid phone number");
        $("sendmsg_phonecode").focus();
        return false;
    }
    if($("sendmsg_coutryfax").value==""||!IsNumber($("sendmsg_coutryfax").value))
    {
        alert("please enter valid fax country code");
        $("sendmsg_coutryfax").focus();
        return false;
    }
    if($("sendmsg_placefax").value==""||!IsNumber($("sendmsg_placefax").value))
    {
        alert("please enter valid fax area code");
        $("sendmsg_placefax").focus();
        return false;
    }
    if($("sendmsg_fax").value==""||!IsNumber($("sendmsg_fax").value))
    {
        alert("please enter valid fax number");
        $("sendmsg_fax").focus();
        return false;
    }
    else
    {
        $("aspnetForm").submit();
    }
}

//var csdnScrollTop=function(){
//        return document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;
//        };
//        function mymove21789(){
//        document.getElementById("smalldiv").style.top=csdnScrollTop()+50+'px';document.getElementById("smalldiv").style.right=3+'px';setTimeout("mymove21789();",50);
//        }
//        mymove21789();
        
        
//window.onresize = resizeDiv(); 
//window.onerror = function(){} 
//var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0; 
//function getMsg() 
//{ 
//try{ 
//divTop = parseInt(document.getElementById("smalldiv").style.top,10) 
//divLeft = parseInt(document.getElementById("smalldiv").style.left,10) 
//divHeight = parseInt(document.getElementById("smalldiv").offsetHeight,10) 
//divWidth = parseInt(document.getElementById("smalldiv").offsetWidth,10) 
//docWidth = document.body.clientWidth; 
//docHeight = document.body.clientHeight; 
//document.getElementById("smalldiv").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight 
//document.getElementById("smalldiv").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth 
//document.getElementById("smalldiv").style.visibility="visible" 
//objTimer = window.setInterval("moveDiv()",10) 
//} 
//catch(e){} 
//} 
//function resizeDiv() 
//{ 
//i+=1 
//if(i>2000) closeDiv() 
//try{ 
//divHeight = parseInt(document.getElementById("smalldiv").offsetHeight,10) 
//divWidth = parseInt(document.getElementById("smalldiv").offsetWidth,10) 
//docWidth = document.body.clientWidth; 
//docHeight = document.body.clientHeight; 
//document.getElementById("smalldiv").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10) 
//document.getElementById("smalldiv").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10) 
//} 
//catch(e){} 
//} 
//function moveDiv() 
//{ 
//try 
//{ 
//if(parseInt(document.getElementById("smalldiv").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10))) 
//{ 
//window.clearInterval(objTimer) 
//objTimer = window.setInterval("resizeDiv()",1) 
//} 
//divTop = parseInt(document.getElementById("smalldiv").style.top,10) 
//document.getElementById("smalldiv").style.top = divTop - 1 
//} 
//catch(e){} 
//} 
//function closeDiv() 
//{ 
//document.getElementById('smalldiv').style.visibility='hidden'; 
//if(objTimer) window.clearInterval(objTimer) 
//} 