﻿// JScript File


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];}
}

Isnumeric = function(e)
 { 
    var keynum;
    var keychar;
    var numcheck;

    if(window.event) //  IE
    {
        keynum = e.keyCode;
    }
    else if(e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
    if(keynum == null || keynum == 8)
        return true

    keychar = String.fromCharCode(keynum);
    numcheck = /\d/;
    return numcheck.test(keychar);
}




function CheckUserType()
{
try{

if (document.getElementById("rdclinet").checked==true)
{
   document.getElementById("rdProfess").checked=false;
   document.getElementById("ctl00_ContentPlaceHolder1_hidUsertype").value="CN";
}
else if (document.getElementById("rdProfess").checked==true)
{
   document.getElementById("rdclinet").checked=false;
   document.getElementById("ctl00_ContentPlaceHolder1_hidUsertype").value="PN";
}
}
catch (ex)
{
}

}

function ValidateTandCs(source, args)
{
   args.IsValid = document.getElementById('ctl00_ContentPlaceHolder1_chkterm').checked;
} 
    
    
function ValidateProjects()
{

 
 var str="ctl00_ContentPlaceHolder1_";
 ///alert(document.getElementById(str+'txtBidDays').value);
 var stralert="";
 if (document.getElementById(str+'txtProjectTtile').value=="")
    stralert = "Please fill the project title. \n";
 
 if (document.getElementById(str+'txtSheduleDate').value=="")
    stralert = stralert+ "Please fill the SheduleDate \n";

  if (validateURL(document.getElementById(str+'txtrefwebsite1').value)== false)
  {
       stralert = stralert+ "Please fill valid similar website url \n";
  }
  if (validateURL(document.getElementById(str+'txtrefwebsite2').value)== false)
  {
       stralert = stralert+ "Please fill valid exciting website url \n";
  }
  if (validateURL(document.getElementById(str+'txtrefwebsite3').value)== false)
  {
       stralert = stralert+ "Please fill valid maintenance existing website Url \n";
  }
 
 if (document.getElementById(str+'ddlprojectType').value=="0")
    stralert = stralert +"Please select the project type.. \n";
  
 if (document.getElementById(str+'txtBidDays').value=="" || document.getElementById(str+'txtBidDays').value == "0" )
    stralert = stralert+ "Please fill the project bid days. \n";
 
 if (document.getElementById(str+'txtProjectDetail').value=="")
    stralert = stralert+ "Please fill the project details. \n";
    
 if (document.getElementById(str+'chkCoptext').checked)
 { if(document.getElementById(str+'brwCopyText').value=="")
     stralert = stralert+ "Please upload the Copy or text file. \n";
 }
 
 if (document.getElementById(str+'chkimgrap').checked)
 {  if(document.getElementById(str+'brwImages').value=="")
    stralert = stralert+ "Please upload the images or graphics file. \n";
 }
    
 if (document.getElementById(str+'chkLayout').checked)
 {  if(document.getElementById(str+'brwLayout').value=="")
    stralert = stralert+ "Please upload the layout or sitemap file. \n";
  
 }
    
 if (document.getElementById(str+'chkAudio').checked)
 {  if(document.getElementById(str+'brwAudio').value=="")
    stralert = stralert+ "Please upload the audio or music file. \n";
  
 }
 if (document.getElementById(str+'txtSheduleDate').value != "ASAP" && Is_Dbnull(dt.Rows[0]["ScheduleDate"], "").ToString() != "DE INMEDIATO")
 {
    if (isValidDate(document.getElementById(str+'txtSheduleDate').value) == false )
    {
        stralert = stralert + "You can fill the ASAP / valid date \n";
        document.getElementById(str+'txtSheduleDate').value = "ASAP";
    }
 }
  
 if(stralert=="")
    return true;  
 else
 {
     alert(stralert);
     return false;
 }

} 

function CheckFieldLength(fn,wn,rn,mc) {

  var len = fn.value.length;
  if (len > mc) {
    fn.value = fn.value.substring(0,mc);
    len = mc;
  }
  document.getElementById(wn).innerHTML = len;
  document.getElementById(rn).innerHTML = mc - len;
}


function isValidDate(strDate){

var day, month, year;
var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
var matchArray = strDate.match(datePat);

if (matchArray == null)
return false;

day = matchArray[1]; // p@rse date into variables
month = matchArray[3];
year = matchArray[5];
month--;

var currentTime = new Date()
var curmonth = currentTime.getMonth() + 1
var curday = currentTime.getDate()
var curyear = currentTime.getFullYear()
 //alert(day + "," +  curday + "," +   month+ "," +  curmonth + "," +   year + "," +  curyear);
 if (day >= curday &&  month > curmonth &&  year >= curyear)
  return true;
 else
   return false; 
}


function validateURL(theurl)
{
  if(theurl != "")
  {
     var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     if (tomatch.test(theurl))
        return true;
     else
        return false; 
   
  }
  return true;

}

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}
// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}
// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }




