    var theWaitWindow = null;     // temporarily window while calling a script
        
    function viewpage(url,width,height) {
      options = "toolbar=0,status=0,menubar=0,scrollbars=1," +
                "resizable=1,width=" + width + ",height=" + height ;
       var mywin = window.open(url,"", options);
    }
    
    
    function _JSWait(msg){
  	  var option = "width=400, height=150," +
			 "resizable=yes,"+
			 "menubar=no," +
			 "toolbar=no," +
			 "location=no," +
			 "status=no, " + 
			 "left=80, " +
			 "top=80 ";
  	  var newWin = window.open('../pwait.php?msg='+ msg,'waitWin',option);
  	  newWin.focus();
  	  return newWin;
    }
    
    var max_len = 225;
    function count(desc){
       var desc_len = desc.value.length;
       if(desc_len < max_len){
          var cnt_id = document.getElementById("maxchar");
          cnt_id.innerHTML = (max_len - desc_len);
       }else{
          alert("You may only type 255 characters in this box");
          desc.focus();
       }
    }
  
 function select(obj,msg){
          obj.focus();
          obj.select();
          alert(msg);
          return false;
    }
    
    function select_menu(obj,msg){
          obj.focus();
          alert(msg);
          return false;
    }    
    function firstUpper(str){
       var b = str.charAt(0).toUpperCase();
       var b = b + str.slice(1,str.length).toLowerCase();
       return b;
    }
    
 
    function is_valid(obj) {
       var invalid = "!\"#%&\'()$;<=>?[\\]*+,-./:^";
       for(i=0;i <invalid.length;i++){
           if(obj.value.indexOf(invalid.charAt(i)) >= 0){
              return false;
           }
       }
       return true;
    }
    
    function is_digit(obj) { 
      var isValid = 1;
      for(i=0;i<obj.value.length;i++){
        var ch = obj.value.charCodeAt(i);
        isvalid = (ch >= 48 && ch <= 57);
        if(!isValid) return false;
      }
      isvalid = !isNaN(obj.value);
      return isvalid;
    }

  function is_empty(obj) {
        obj.value = L_trim(obj);
        obj.value = R_trim(obj);
      	if ((obj.value.length==0) || (obj.value==null)) {
         return true;
        }else{
           return false;
        }
    }
    
    function L_trim(obj){
       var hasChar = false;
       var tempObjVlaue = "";
       for(i = 0; i < obj.value.length ; i++){
          cur_char = obj.value.charCodeAt(i);
          if(cur_char != 32)
            hasChar = true;
            
          if(hasChar)
             return obj.value.substr(i);
       }
       return obj.value;
    }
    

    function R_trim(obj){
       var hasChar = false;
       var tempObjVlaue = "";
       var cur_char = "";
       for(i = obj.value.length; i >= 0 ; i--){
          cur_char = obj.value.charCodeAt(i-1);
          if(cur_char != 32)
            hasChar = true;
            
          if(hasChar){
             return obj.value.substr(0,i);
          }   
       }
       return obj.value;
    }
    
//////////////

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function check_Phone(strPhone){
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}


   
    function isValidPhone(phone) {
	   var valid = true;
		filterPhone= /^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}( x\d{0,})?/
		///(^(\+?\-? *[0-9]+)-([,0-9 ]*)-([0-9 ])*$)|(^ *$)/
	   if(filterPhone.test(phone) != true){
	   	valid = false;
	   }
	   return valid; 
    }
    function isValidUrl(url) {
	   var valid = true;
		filterUrl= /^(\w+)\.([\-\+a-z0-9]*)$/
	   if(filterUrl.test(url) != true){
	   	valid = false;
	   }
	   return valid; 
    }

    function isValidEmail(str) {
       // are regular expressions supported?
		var flag = true;
	    filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(str)!= true){
			flag = false;
	    } 
    	return flag;
    }
    
    //Wait Window to be close onloead
    function _wait_window(){
      if(theWaitWindow != null)
        theWaitWindow.close();
   }
    function loadPicture(id,f){
     document.images[id].src = f; 
  }

  function change_bg(obj,color){
	   obj.style.background = color;
  }   

  

  
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


/** start project view**/
       var project_list = {"projects":[
       
                                         {	"name": "Behnevis",
                                         	"url" : "http://www.behnevis.com/",
                                         	"picture" : "behnevis.gif"
                                         },
                                         {	"name": "Iran Gift Land",
                                         	"url" : "http://www.irangiftland.com",
                                         	"picture" : "irang_gift_land.gif"
                                         },
                                         {	"name": "Canada Mortgage Plus",
                                         	"url" : "http://www.canadamortgageplus.com",
                                         	"picture" : "canadamortgageplus.gif"
                                         },       
                                         {	"name": "Paymate Software",
                                         	"url" : "http://www.paymatesoftware.com",
                                         	"picture" : "paymate.gif"
                                         },                                         
                                         {	"name": "Canon DVD",
                                         	"url" : "http://www.canondvd.com",
                                         	"picture" : "canondvd.gif"
                                         },
                                         {	"name": "Air Makers Inc.",
                                         	"url" : "http://www.airmakers.ca",
                                         	"picture" : "airmakers.jpg"
                                         },
                                         {	"name": "Immigration Consultancy",
                                         	"url" : "http://www.mcimmigration.com/",
                                         	"picture" : "mcimmigration.jpg"
                                         },
                                         
                                         {	"name": "Marvelous Marble Design",
                                         	"url" : "http://www.marvelousmarbledesign.com",
                                         	"picture" : "marvelous_marble_design.gif"
                                         },
                                         {	"name": "Unique Home Organizer",
                                         	"url" : "http://www.uniquehomeorganizer.com",
                                         	"picture" : "unique_home_organizer.gif"
                                         },
                                         {	"name": "Signature Motor Car Inc",
                                         	"url" : "http://www.signaturemotor.com",
                                         	"picture" : "signaturemotor.gif"
                                         },           
                                         {	"name": "PGD Canada",
                                         	"url" : "http://www.pgdcanada.com",
                                         	"picture" : "pgdcanada.gif"
                                         },                                         
                                         {	"name": "Microhouse Systems Inc",
                                         	"url" : "http://www.mhsystems.com",
                                         	"picture" : "microhouse_systems.gif"
                                         },
                                         {	"name": "Soltanian Custome Home",
                                         	"url" : "http://www.webrunhost.com/dev/soltanian/",
                                         	"picture" : "soltanian.gif"
                                         },                                         
                                         {	"name": "Artpix",
                                         	"url" : "http://www.artpix.ca",
                                         	"picture" : "artpix.gif"
                                         },
                                         {	"name": "Castims Inc",
                                         	"url" : "http://www.castimis.ca",
                                         	"picture" : "castimis.gif"
                                         },
                                         {	"name": "Gissa Music",
                                         	"url" : "http://www.gissiamusic.com",
                                         	"picture" : "gissia_music.gif"
                                         },
                                         {	"name": "Pen WoodWorking",
                                         	"url" : "http://www.penwood.com",
                                         	"picture" : "penwoodworking.gif"
                                         },                                         
                                        /* {	"name": "World Wide Immigration Services Inc",
                                         	"url" : "http://www.wwis.ca",
                                         	"picture" : "wwis.jpg"
                                         },*/
                                         {	"name": "Iran Poster",
                                         	"url" : "http://www.iranposter.com",
                                         	"picture" : "iranposter.gif"
                                         },
                                         {	"name": "Imran Nurali",
                                         	"url" : "http://www.imrannurali.net",
                                         	"picture" : "imranNuraliev.gif"
                                         },
                                         {	"name": "Tire Canada",
                                         	"url" : "http://www.tirecanada.ca",
                                         	"picture" : "tirecanada.gif"
                                         },
                                         {	"name": "Hassan Yousefzamani",
                                         	"url" : "http://www.yousefzamani.com",
                                         	"picture" : "yousefzamani.gif"
                                         },
                                         {	"name": "Free To Air Receivers",
                                         	"url" : "http://www.ftareceivers.net",
                                         	"picture" : "ftareceivers.gif"
                                         },
                                         {	"name": "Cima Media International Productions",
                                         	"url" : "http://www.cmip.ca",
                                         	"picture" : "cmip.gif"
                                         },
                                         {	"name": "Monaco Cabinetry",
                                         	"url" : "http://www.monacocabinet.com",
                                         	"picture" : "monaco.gif"
                                         },
                                         {	"name": "Azi Portrait Studio",
                                         	"url" : "http://aziportraitstudio.com",
                                         	"picture" : "aziportrait.gif"
                                         },
                                         {	"name": "Beauty By Laser",
                                         	"url" : "http://www.beautybylaser.ca",
                                         	"picture" : "beautybylaser.gif"
                                         },
                                         {	"name": "Califund Inc",
                                         	"url" : "http://www.califund.com",
                                         	"picture" : "califundinc.gif"
                                         },
                                         {	"name": "Canadian Zurkhaneh",
                                         	"url" : "http://www.canadianzurkhaneh.com",
                                         	"picture" : "canadianzurkhaneh.gif"
                                         },
                                         {	"name": "CBR Rij School",
                                         	"url" : "http://www.cbr-rijschool.nl",
                                         	"picture" : "cbr-rijschool.gif"
                                         },
                                         {	"name": "HFC Canada",
                                         	"url" : "http://www.hfccanada.com",
                                         	"picture" : "hfccanada.gif"
                                         },
                                         {	"name": "MPrecast Systems",
                                         	"url" : "http://www.mprecastsystems.com",
                                         	"picture" : "mprecastsystems.gif"
                                         },
                                         {	"name": "Dent Temp Plus",
                                         	"url" : "http://www.denttempplus.com",
                                         	"picture" : "temp_dent_plus.gif"
                                         },
                                         {	"name": "On The Way Limo",
                                         	"url" : "http://www.onthewaylimo.com",
                                         	"picture" : "onthewaylimo.gif"
                                         },
                                         {	"name": "Honey Driving School",
                                         	"url" : "http://www.honeydrivers.com",
                                         	"picture" : "honeydrivingschool.gif"
                                         }
                                         
       				      ]
       				      };

    var p_index = -1;


    function  view_project(){
       i = 0;
       if(project_list.projects.length-1 == p_index)
       {
         i = p_index = 0;
       }
       else
       {
         p_index++;
       }

        for (var prop in project_list.projects) {

	        if(p_index == i++){
	            var project =   "<span class='project_title' > " + project_list.projects[prop].name + "</span><br /> <a href='#' onclick='view_project();return false;' onmouseout=\"window.status=''\" onmouseover=\"window.status='" + project_list.projects[prop].name + "'\">Next</a><br /><br /><a target='_blank' href='" + project_list.projects[prop].url + "'><img src=\"http://www.webrun.ca/images/projects/" + project_list.projects[prop].picture + "\" border='0'  alt=\"webrun sample project sample\" /></a><br /><br />";
	        	document.getElementById("project").innerHTML = project;
	        	return;
	        }

	    }

    }