

var expiration = new Date();

var months = new Array();
months[1] = "January"
months[2] = "February"; 
months[3] = "March"; 
months[4] = "April"; 
months[5] = "May"; 
months[6] = "June"; 
months[7] = "July";
months[8] = "August"; 
months[9] = "September"; 
months[10] = "October"; 
months[11] = "November"; 
months[12] = "December";
//var nowCount = 2;


function job_validate() {  

   if ( IsEmpty(document.main.title.value) ) {
     alert("Job Title cannot be empty");
     document.main.title.focus();
     return false;
   }
/*   
   if ( IsEmpty(document.main.description.value) ) {
     alert("Description cannot be empty");
     document.main.description.focus();
     return false;
   }
   if ( IsEmpty(document.main.contact_name.value) ) {
     alert("Contact Name cannot be empty");
     document.main.contact_name.focus();
     return false;
   }
   if ( IsEmpty(document.main.contact_telephone.value) ) {
     alert("Contact Telephone cannot be empty");
     document.main.contact_telephone.focus();
     return false;
   }
   if ( IsEmpty(document.main.contact_fax.value) ) {
     alert("Contact Fax cannot be empty");
     document.main.contact_fax.focus();
     return false;
   }
   if ( IsEmpty(document.main.contact_email.value) ) {
     alert("Contact Email cannot be empty");
     document.main.contact_email.focus();
     return false;
   }
*/

   nowCount = parseInt(document.getElementById("count_cat_id_ads").value);
   if(nowCount < 1){
     alert("You must choose a category");
     return false;
   }
}


function player_popup(){

   m = 'rant/OfficialRant.html';

   

   w = 324;

   h = 302;



   var agt=navigator.userAgent.toLowerCase();

   if(agt.indexOf('chrome') != -1){



   } else if(agt.indexOf('safari') != -1){

      w = 333;

      h = 326;



   }



   var scroll = 'no';

   var settings;

   var LeftPosition;

   var TopPosition;

   var win;



   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;

   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;



   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;

   settings = settings + ',resizable=no,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no, navigator=no';



   win = window.open(m, 'popup', settings);



}





expiration.setTime(expiration.getTime() + 3600*3600*3600);



function view_duplicate(){

   document.getElementById('view_duplicate').value = "view_duplicate";

   document.main.submit();

}



function view_search(){

   document.getElementById('view_duplicate').value = "view_search";

   document.main.submit();

}



function delete_checked(){

   document.getElementById('view_duplicate').value = "delete_checked";

   document.main.submit();

}



function discard(ind){

   document.getElementById('name'+ind).value = '';

   document.getElementById('email'+ind).value = '';

   document.getElementById('town'+ind).value = '';

   document.getElementById('country'+ind).value = '';

   document.getElementById('error'+ind).innerHTML = '';

   document.getElementById('label_name'+ind).style.color = "#333333";

   document.getElementById('label_name'+ind).style.fontWeight = "400";

   document.getElementById('label_email'+ind).style.color = "#333333";

   document.getElementById('label_email'+ind).style.fontWeight = "400";

   document.getElementById('label_town'+ind).style.color = "#333333";

   document.getElementById('label_town'+ind).style.fontWeight = "400";

   document.getElementById('label_view'+ind).style.color = "#333333";

   document.getElementById('label_view'+ind).style.fontWeight = "400";

   document.getElementById('your-view'+ind).value = '';



   document.getElementById('replay_comment_'+ind).style.display = "none";

  

   return false;

}



function have_say(){

  document.getElementById("have_say_1").style.display = "none";

  document.getElementById("hide_say_1").style.display = "block";



  if(document.getElementById("count_comment").value == 1){

     document.getElementById("have_say_2").style.display = "none";

     document.getElementById("hide_say_2").style.display = "block";

  }  else {

     document.getElementById("have_say_2").style.display = "none";

     document.getElementById("hide_say_2").style.display = "none";

  }

  

  document.getElementById("comment_form").style.display = "block";

}



function hide_form(){

  document.getElementById("have_say_1").style.display = "block";

  document.getElementById("hide_say_1").style.display = "none";



  if(document.getElementById("count_comment").value == 1){

     document.getElementById("have_say_2").style.display = "block";

     document.getElementById("hide_say_2").style.display = "none";

  } else {

     document.getElementById("have_say_2").style.display = "none";

     document.getElementById("hide_say_2").style.display = "none";

  }



  

  document.getElementById("comment_form").style.display = "none";



}





function allow_view_replay_comment(ind){

  style_display = document.getElementById("replay_comment_"+ind).style.display;

  if(style_display == 'block'){

     style_display = 'none';

  } else {

     style_display = 'block';

  }



  document.getElementById("replay_comment_"+ind).style.display = style_display;

}



function edit_News(){


  if(!document.getElementById("list_cat_id_news").value){

    alert("Error! Category must be selected.");

    return false;

  }
  
  //alert(document.getElementById("article_description").value);
  /*
  if(!document.getElementById("article_description").value){

    alert("Error! Subtitle must be entered.");

    return false;

  }
  */
  return true;

}



function plan_3_99(){

  for (i = 0; i < document.main.elements.length; i++) {

    var item = document.main.elements[i];  

    if (item.name == "product_id") {  

        if(item.value == -1){

           alert("By default you are charged $3.99 for each news item and/or classified ad you post. No change has been made.");  

           return false;

        }  else return true;

    } 

  }   

}



function set_title(){



  for (i = 0; i < document.main.elements.length; i++) {

    var item = document.main.elements[i];  

    if (item.name == "titles[]") {  

        document.getElementById('title').value = item.value;

    }

  }



}



function set_title1(){



  for (i = 0; i < document.main1.elements.length; i++) {

    var item = document.main1.elements[i];  

    if (item.name == "titles[]") {  

        document.getElementById('title').value = item.value;

    }

  }



}





function check_by_cat(id) {



  for (i = 0; i < document.main.elements.length; i++) {

    var item = document.main.elements[i];

    if (item.name == "chck_by_cat[]" && item.value == id) {

                      

      for (j = 0; j < document.main.elements.length; j++) {

        var item2 = document.main.elements[j];



           if (item2.name == "hidden_ids_for["+id+"]") {

           eval("var a1 = Array("+item2.value+");");



              for(var _a in a1){

                var _id =a1[_a];



                document.getElementById('chck_cat_'+_id).checked = item.checked;

                document.getElementById('chck_cat_'+_id).onchange();

              }

           }

      }

    }

  }

}



function changeColorCategory(catid){

  col = 0;



  for (var i = 0; i < document.main.elements.length; i++) {

    var item = document.main.elements[i];



    if (item.type == "checkbox") {

      if(item.checked) {

         col = 1;

      }

    }

  }

       

  if(col == 1){ 

    opener.document.getElementById('chck_cat_'+catid).className = "has_child";

  } else {

    was_chacked = document.getElementById('cat_checked').value;



    if(was_chacked){



       opener.document.getElementById('chck_cat_'+catid).className = "has_child";

       //opener.document.getElementById('chck_cat_'+catid).value = "1";

    } else {

       opener.document.getElementById('chck_cat_'+catid).className = "no_child";

    }

  }

}



function closeCatWindow(){
  catname = document.getElementById('catname').value;
  opener.document.getElementById('list_cat_id_'+catname).value = document.getElementById('list_cat_id_'+catname).value;
  opener.document.getElementById('count_cat_id_'+catname).value = document.getElementById('count_cat_id_'+catname).value;
}

function viewSubCatWindow(redirect_url, ind, n) { 

   var scroll = 'yes';

   var settings;

   var LeftPosition;

   var TopPosition;

   var win;

   w = 600;

   h = 400;

   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;

   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;

   settings = settings + ',resizable=no,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no';

   var chck_cat=document.getElementById("list_cat_id_"+n).value;

   win = window.open(redirect_url+"&category_ref="+ind+"&chck_cat="+chck_cat, 'pre', settings);

   win.name = 'name';

   win.focus();
}


function showContact(redirect_url, ind) { 

   var scroll = 'yes';
   var settings;
   var LeftPosition;
   var TopPosition;
   var win;

   w = 500;
   h = 300;

   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;
   settings = settings + ',resizable=no,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no';

   win = window.open(redirect_url+"&user_ref="+ind, 'pre', settings);
   win.name = 'name';
   win.focus();
}




function checkMaxCount(id){

   maxCount = 3;



   nowCount = parseInt(document.getElementById("count_cat_id_news").value);

   str = document.getElementById("list_cat_id_news").value;



   elem = id+",";



   if(!str) str = '';

   if(!nowCount) nowCount = 0;

                                         

   if (document.getElementById('chck_cat_'+id).checked == false){



     pos = str.indexOf(elem);



     if(pos != -1){

       massiv = str.split(elem);

       str = massiv[0]+massiv[1];



     }

     nowCount--;



   } 

   

   if (document.getElementById('chck_cat_'+id).checked == true){

        

      if(nowCount >= maxCount){

         alert("You are only permitted to select 3 categories.  Be specific.");

         document.getElementById('chck_cat_'+id).checked = false;

      } else {

          nowCount++;

          str += elem;

      }

   }

     document.getElementById("count_cat_id_news").value = nowCount;

     document.getElementById("list_cat_id_news").value = str;

}





function checkMaxCountClassifieds(id){

   maxCount = 3;



   nowCount = parseInt(document.getElementById("count_cat_id_ads").value);

   str = document.getElementById("list_cat_id_ads").value;

   /*

   nowCount = parseInt(GetCookie('ItemCount'));

   str = GetCookie('ClassItemStringId');

   */

   elem = id+",";



   if(!str) str = '';

   if(!nowCount) nowCount = 0;

                                         

   if (document.getElementById('chck_class_cat_'+id).checked == false){



     pos = str.indexOf(elem);



     if(pos != -1){

       massiv = str.split(elem);

       str = massiv[0]+massiv[1];



     }

     nowCount--;

   } 

   

   if (document.getElementById('chck_class_cat_'+id).checked == true){

        

      if(nowCount >= maxCount){

         alert("You are only permitted to select 3 category.  Be specific.");

         document.getElementById('chck_class_cat_'+id).checked = false;

      } else {

          nowCount++;

          str += elem;

      }

   }

   //alert(nowCount);

   document.getElementById("count_cat_id_ads").value = nowCount;

   document.getElementById("list_cat_id_ads").value = str;

     /*

   SetCookie('ItemCount',nowCount,expiration, '', '','');

   SetCookie('ClassItemStringId',str,expiration, '', '','');

   */

}



function fullCookie(n, field_name, id){

           

   //str = GetCookie(cookie_name);

   str = document.getElementById("list_cat_id_"+n).value;



   elem = id+",";



   if(!str) str = '';

                                     //field_name    = chck_cat_

   if (document.getElementById(field_name+id).checked == false){

      pos = str.indexOf(elem);



      if(pos != -1){

        massiv = str.split(elem);

        str = massiv.join('');

      }

   } 

   

   if (document.getElementById(field_name+id).checked == true){

      str += elem;

   }



   document.getElementById("list_cat_id_"+n).value = str;

   //SetCookie(cookie_name,str,expiration, '', '','');


}



function check_date(){



  var dd = parseInt(document.main.dd.value);

  var mm = parseInt(document.main.mm.value);

  var yy = parseInt(document.main.yy.value);

   

  var my_error = "";



  if(!yy) {

     my_error += "Year should'n be empty!<br />";

  }

  if(my_error != "") {

    document.getElementById('error').innerHTML = my_error;

     return false;

  } else {

      this.submit();

  }



}



function check_the_count(){



  img_count = document.main.count_images.value;

  document.main.action.value = document.main.action_before.value;

  document.main.submit();

}



function SetCookie(name, value, expires, path, domain, secure) { 



   var mycookie = name + "=" + escape(value);

   var myexpires = new Date();

   myexpires.setTime(myexpires.getTime() + 5000);

   mycookie = mycookie + "; myexpires=" + myexpires.toGMTString();

   document.cookie = mycookie;

}





function GetCookie(name) { 

   var arg = name + "="; 

   var alen = arg.length; 

   var clen = document.cookie.length; 

   var i = 0; 



   while (i < clen) { 

     var j = i + alen; 

     if (document.cookie.substring(i, j) == arg)  return getCookieVal (j); 

     i = document.cookie.indexOf(" ", i) + 1; 

     if (i == 0) break; 

   }

    

   return null; 

} 



function getCookieVal (offset) { 

  var endstr = document.cookie.indexOf (";", offset); 

  if (endstr == -1) endstr = document.cookie.length; 

   return unescape(document.cookie.substring(offset, endstr)); 

} 



function validEmail(email) {

  invalidChars = " /:,;";

  if (email == "") {

    return false;

  }

  for (i=0; i<invalidChars.length;i++) {

    badChar = invalidChars.charAt(i);

    if (email.indexOf(badChar,0) > -1) {

      return false;

    }

  }

  atPos = email.indexOf("@",1);

  if (atPos == -1) {

    return false;

  }

  if (email.indexOf("@",atPos+1) > -1) {

    return false;

  }

  periodPos = email.indexOf(".",atPos);

  if (periodPos == -1) {

    return false;

  }

  if (periodPos+3 > email.length) {

    return false;

  }

  return true;

}





function checkCommentFiels(ind) {



  name = document.getElementById('name'+ind).value;

  email = document.getElementById('email'+ind).value;

  town = document.getElementById('town'+ind).value;

  country = document.getElementById('country'+ind).value;

  your_view = document.getElementById('your-view'+ind).value;

  my_error = '';                             



  document.getElementById('error'+ind).innerHTML = my_error;



  if(name == ''){

    my_error += "* Please enter the Name<br/>";

    document.getElementById('label_name'+ind).style.color = "#bd0000";

    document.getElementById('label_name'+ind).style.fontWeight = "700";

  } else {

    document.getElementById('label_name'+ind).style.color = "#333333";

    document.getElementById('label_name'+ind).style.fontWeight = "400";

  }

  

  if(email == ''){

    my_error += "* Please enter the Email<br/>";

    document.getElementById('label_email'+ind).style.color = "#bd0000";

    document.getElementById('label_email'+ind).style.fontWeight = "700";

  } else {

    document.getElementById('label_email'+ind).style.color = "#333333";

    document.getElementById('label_email'+ind).style.fontWeight = "400";

    if(!validEmail(email)){

      my_error += "* Please enter a valid Email<br/>";

      document.getElementById('label_email'+ind).style.color = "#bd0000";

      document.getElementById('label_email'+ind).style.fontWeight = "700";

    } else {

      document.getElementById('label_email'+ind).style.color = "#333333";

      document.getElementById('label_email'+ind).style.fontWeight = "400";

    }

  }



  if(town == ''){

    my_error += "* Please enter the city<br/>";

    document.getElementById('label_town'+ind).style.color = "#bd0000";

    document.getElementById('label_town'+ind).style.fontWeight = "700";

  } else {

    document.getElementById('label_town'+ind).style.color = "#333333";

    document.getElementById('label_town'+ind).style.fontWeight = "400";

  }



  if(your_view == ''){

    my_error += "* Please enter the comment<br/>";

    document.getElementById('label_view'+ind).style.color = "#bd0000";

    document.getElementById('label_view'+ind).style.fontWeight = "700";

  } else {

    var str_com = your_view;



    var reg_com = new RegExp("([a-z]+):\/\/([^?#/:]+)", "gi");

    var reg_com1 = new RegExp("(\\.)(net|org|co\.uk|ru|com)", "gi");



    if(reg_com.test(str_com) || reg_com1.test(str_com)){

       my_error += "* URLs and Email Address(es) are not permitted.<br/>";

       document.getElementById('your-view'+ind).value = "";

       document.getElementById('label_view'+ind).style.color = "#bd0000";

       document.getElementById('label_view'+ind).style.fontWeight = "700";

    } else {

       document.getElementById('label_view'+ind).style.color = "#333333";

       document.getElementById('label_view'+ind).style.fontWeight = "400";

    }

  }



  if(my_error) {

    my_error = "Error:<br/>"+my_error;   

    document.getElementById('error'+ind).innerHTML = my_error;

    return false;

  } else {

    document.getElementById('ind').value = ind;

    return true;

  }



}



function disableselect(e){ 

return false 

}



var nTotalCharacters = 1000;



function fCountCharacters(sValue,sId, ch) {

        if(ch) ch1 = ch; else ch1 = nTotalCharacters;



    var nRemaining = ch1 - sValue.length;

    if(nRemaining < 0){

        document.getElementById(sId).value = sValue.slice(0,ch1);

    } else {

        document.getElementById(sId + '-characters-left').innerHTML = nRemaining + ' characters left';

    }

}







function reEnable(){ 

return true 

} 

//if IE4+ 

//document.onselectstart=new Function ("return false") 

//if NS6 

//if (window.sidebar){ 

//document.onmousedown=disableselect 

//document.onclick=reEnable 

//} 



function Check() {

    var f = false;



    for(i=0; i<document.voteform.vote.length; i++)

        if(document.voteform.vote[i].checked) f = true;



    return f;

}



function ChangeVote(obj) {

    document.voteform.vote.value = obj.getAttribute("v");

    document.voteform.submit();



}



function MOver(obj, img) {

    var elmImg = document.getElementById(img);

    if (elmImg.disabled)

        return;

    elmImg.src = obj.getAttribute("i");

}

    

function MOut(img) {

    var elmImg = document.getElementById(img);

    if (elmImg.disabled)

        return;

    var originalImg = elmImg.getAttribute("originalImg");

    elmImg.src = originalImg;

}





var pre;



function preview(main, tag) {

//    var tag = "$TAG";



//  if (pre != '') { pre.close(); }

  if(tag == 0){

    tag = '';

  }

  pre = window.open("", "pre", "resizable=yes,scrollbars=yes,status=no,toolbar=no,directories=no,menubar=no,location=no");

  pre.name = "pre";

  pre.document.writeln("<html><head><title>OfficialWire: Your Official News Source</title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"><link href=\"style.css\" type=text/css rel=stylesheet></head><body leftmargin=\"0\" topmargin=\"0\"><div color=\"#FFFFFF\" width=\"100%\"><table width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">  <tr> <td class=\"mtext\">");

  pre.document.writeln("<br><h2>"+document.main.title.value+"</h2>");

  pre.document.writeln("<h2>"+document.main.description.value+"</h2>");

  prebody = '';

  if(main.point.value > "") { 

        if(tag) tag += " OfficialWire"; else tag = "OfficialWire";

        prebody =  "Published on " + months[document.main.distrdatemm.value*1] + " " + main.distrdatedd.value + ", 20" +  document.main.distrdateyy.value + "<br>  " 
                   + "<br>(" + tag + ")<br><br>" + document.main.point.value;
    }

  pre.document.writeln(prebody+document.main.body.value);

  pre.document.writeln("</td></tr><tr><td  class=\"mtext\">"+"<br><hr><br>");

  pre.document.writeln("<br><br><center><input type=\"image\" src=\"images/close.gif\" border=\"0\" onclick=\"javascript:window.close();\"> &nbsp;</center>");

  pre.document.writeln("</td></tr></table></div></body></html>");

  pre.document.close();

  pre.focus();

}







function SubmitRecipient(main) {

   if (!(validEmail(document.main.email.value))) { alert("Email must be valid"); return false; }

   if (!(get_selects(document.main.recents))) { return false; }

   return true;

}



function IsEmpty (data) {

        if (data.length == 0) {

                return true;

        } else {

                return false;

        }

}



function ad_category_validate() {  

   if ( IsEmpty(main.name.value) ) {

     alert("Category name cannot be empty");

     document.main.name.focus();

     return false;

   }

   if ( IsEmpty(main.description.value) ) {

     alert("Category description cannot be empty");

     document.main.description.focus();

     return false;

   }

   if (document.main.display_browse.checked) {

      document.main.d_browse.value = 1;

   } else {

      document.main.d_browse.value = 0;

   }

}



function ad_validate() {  



   if ( IsEmpty(document.main.name.value) ) {

     alert("Ad name cannot be empty");

     document.main.name.focus();

     return false;

   }



   if ( IsEmpty(document.main.target_url.value) ) {

     alert("Site URL cannot be empty");

     document.main.target_url.focus();

     return false;

   }



   nowCount = parseInt(document.getElementById("count_cat_id_ads").value);

   //nowCount = parseInt(GetCookie('ItemCount'));



   if(nowCount != 1){

     alert("You must choose a category");

     return false;



   }



}



function ad_comment_validate() {

  if ( IsEmpty(document.main.name.value) ) {

     alert("Username cannot be empty");

     document.main.name.focus();

     return false;

  }

  if (!(validEmail(document.main.email.value))) { alert("Email must be valid"); return false; }



  if ( IsEmpty(document.main.town.value) ) {

     alert("Town cannot be empty");

     document.main.town.focus();

     return false;

  }



  if ( IsEmpty(document.main.comment.value) ) {

     alert("Comment cannot be empty");

     document.main.comment.focus();

     return false;

  }



}



function submitIt2() {

  if ( IsEmpty(document.main.firstname.value) ) {

    alert("First Name cannot be empty");

    document.main.firstname.focus();

    return false;

  }

  if ( IsEmpty(document.main.lastname.value) ) {

    alert("Last Name cannot be empty");

    document.main.lastname.focus();

    return false;

  }

  if ( IsEmpty(main.title.value) ) {

    alert("Title cannot be empty");

    document.main.title.focus();

    return false;

  }

  if ( IsEmpty(main.phone.value) ) {

    alert("Phone cannot be empty");

    document.main.phone.focus();

    return false;

  }

  if ( IsEmpty(main.phone2.value) ) {

    alert("After Hours Phone cannot be empty");

    document.main.phone2.focus();

    return false;

  }

  if ( IsEmpty(main.fax.value) ) {

    alert("Fax cannot be empty");

    document.main.fax.focus();

    return false;

  }

  /*

  if ( IsEmpty(main.department.value) ) {

    alert("Department/Location cannot be empty");

    document.main.department.focus();

    return false;

  }



  */

  return true;

}



function submitIt_payment() {

  if ( IsEmpty(main.name.value) ) {

    alert("Name cannot be empty");

    document.main.name.focus();

    return false;

  }

  if ( IsEmpty(main.address.value) ) {

    alert("Address cannot be empty");

    document.main.address.focus();

    return false;

  }

  if ( IsEmpty(main.postcode.value) ) {

    alert("PostCode cannot be empty");

    document.main.postcode.focus();

    return false;

  }

  if ( IsEmpty(main.tel.value) ) {

    alert("Phone cannot be empty");

    document.main.tel.focus();

    return false;

  }

  if (!validEmail(main.email.value)) {

    alert("Invalid email address");

    document.main.email.focus();

    document.main.email.select();

    return false;

  }

}



function submitIt() {

  if (!validEmail(main.username.value)) {

    alert("Invalid email address");

    document.main.username.focus();

    document.main.username.select();

    return false;

  }

  var str = main.username.value;

  var f = str.match(/@otenet/gi);

  if (f) { 

    var msg="Your OTENET.GR webmaster has blocked Email sent from our server because our parent company owns OTENET.COM.  Therefore we cannot authorize your registration with our site.  If you can use another non-OTENET Email account, please enter it now.  We apologise for this inconvenience.  You should write and complain to your service provider.";

    alert(msg);

    document.location.href="static.php?action=home";   

    return false;

  }

  if ( IsEmpty(main.password.value) ) {

    alert("Password cannot be empty");

    document.main.password.focus();

    return false;

  }

  if ( IsEmpty(main.password2.value) ) {

    alert("Confirm password cannot be empty");

    document.main.password2.focus();

    return false;

  }

  if ( (main.password.value != main.password2.value) || (!main.password.value) ) {

    alert("Invalid password");

    document.main.password.focus();

    return false;

  }

  if ( IsEmpty(main.firstname.value) ) {

    alert("First Name cannot be empty");

    document.main.firstname.focus();

    return false;

  }

  if ( IsEmpty(main.lastname.value) ) {

    alert("Last Name cannot be empty");

    document.main.lastname.focus();

    return false;

  }

  if ( IsEmpty(main.title.value) ) {

    alert("Title cannot be empty");

    document.main.title.focus();

    return false;

  }

  if ( IsEmpty(main.company.value) ) {

    alert("Account/Company cannot be empty");

    document.main.company.focus();

    return false;

  }

  if ( IsEmpty(main.address.value) ) {

    alert("Address cannot be empty");

    document.main.address.focus();

    return false;

  }

//  if ( IsEmpty(main.suite.value) ) {

//    alert("Suite/PO Box cannot be empty");

//    main.suite.focus();

//    return false;

//  }

  if ( IsEmpty(main.city.value) ) {

    alert("City cannot be empty");

    document.main.city.focus();

    return false;

  }

  if ( IsEmpty(main.state.value) ) {

    alert("State cannot be empty");

    document.main.state.focus();

    return false;

  }

  if ( IsEmpty(main.country.value) ) {

    alert("Country cannot be empty");

    document.main.country.focus();

    return false;

  }

  if ( IsEmpty(main.zip.value) ) {

    alert("PostCode cannot be empty");

    document.main.zip.focus();

    return false;

  }

  if ( IsEmpty(main.phone.value) ) {

    alert("Phone cannot be empty");

    document.main.phone.focus();

    return false;

  }

 /* if ( IsEmpty(main.fax.value) ) {

    alert("Fax cannot be empty");

    document.main.fax.focus();

    return false;

  }*/

 /* if ( IsEmpty(main.url1.value) ) {

    alert("URL cannot be empty");

    document.main.url1.focus();

    return false;

  }*/

 /* if ( IsEmpty(main.phone2.value) ) {

    alert("After Hours Phone cannot be empty");

    document.main.phone2.focus();

    return false;

  }  */

   /*

   alert(document.main.chck_cat);

   return false;

              //$chck_cat, $chck_ad_cat,

   news_sel = document.main.chck_cat;

   

   alert(news_sel);

   return false;



   res = '';

   for (Count = 0; Count < news_sel.length; Count++) 

   {

      if (news_sel[Count].selected) 

      {

         if (res) 

         {

            res = res + ','+sel[Count].value; 

         }

         else

         {

            res += sel[Count].value; 

         }

      }

   }

   document.main.selects.value=res;



  */



  return true;

}


function submitIt_edit() {

  if (!validEmail(document.main.username1.value)) {

    alert("Invalid email address");

    document.main.username1.focus();

    document.main.username1.select();

    return false;

  }

   
  if ( IsEmpty(document.main.password1.value) ) {

    alert("Password cannot be empty");

    document.main.password1.focus();

    return false;

  }

  if ( IsEmpty(document.main.firstname.value) ) {

    alert("First Name cannot be empty");

    document.main.firstname.focus();

    return false;

  }

  if ( Check_Lengthlow(document.main.firstname.value, 3) ) {

    alert("First Name cannot be under 3 symbols");

    document.main.firstname.focus();

    return false;

  }    
  
  if ( IsEmpty(document.main.lastname.value) ) {

    alert("Last Name cannot be empty");

    document.main.lastname.focus();

    return false;

  }

  if ( Check_Lengthlow(document.main.lastname.value, 3) ) {

    alert("Last Name cannot be under 3 symbols");

    document.main.lastname.focus();

    return false;

  }    

  if ( IsEmpty(document.main.title.value) ) {

    alert("Title cannot be empty");

    document.main.title.focus();

    return false;

  }

  if ( IsEmpty(document.main.company.value) ) {

    alert("Account/Company cannot be empty");

    document.main.company.focus();

    return false;

  }

  if ( IsEmpty(document.main.address.value) ) {

    alert("Address cannot be empty");

    document.main.address.focus();

    return false;

  }

//  if ( IsEmpty(main.suite.value) ) {

//    alert("Suite/PO Box cannot be empty");

//    main.suite.focus();

//    return false;

//  }

  if ( IsEmpty(document.main.city.value) ) {

    alert("City cannot be empty");

    document.main.city.focus();

    return false;

  }

  if ( IsEmpty(document.main.state.value) ) {

    alert("State cannot be empty");

    document.main.state.focus();

    return false;

  }

  if ( IsEmpty(document.main.country.value) ) {

    alert("Country cannot be empty");

    document.main.country.focus();

    return false;

  }

  if ( IsEmpty(document.main.zip.value) ) {

    alert("PostCode cannot be empty");

    document.main.zip.focus();

    return false;

  }

  if ( IsEmpty(document.main.phone.value) ) {

    alert("Phone cannot be empty");

    document.main.phone.focus();

    return false;
  }

  return true;

}

function Check_Lengthlow(field_name,lenval)
{
    var lenval1;
    lenval1=field_name;
    var lval;
    lval=lenval1.length;
    if(lval< lenval)
    {
        return true;
    }
    
    return false;
}


function getaccountinf() {

   document.main.action.value="account";

   document.main.submit();

   return true;

}





function getcontactinf() {

   document.main.action.value="contact";

   document.main.submit();

}





function getbillinginf() {

   document.main.action.value="billing";

   document.main.submit();

}





function setmailtoactiveinf() {

   document.main.action.value="mailtoactive";

   document.main.submit();

}



 /*continue*/

function viewterms(main) {

//   if (pre != '') { pre.close(); }

   pre = window.open("static.php?action=terms.popup", "pre", "width=600,height=400,resizable=yes,scrollbars=yes,status=no,toolbar=no,directories=no,menubar=no,location=no");

   pre.focus();

}



function viewconvert(main) { 

//   if (pre != '') { pre.close(); }

   pre = window.open("static.php?action=convert.popup", "pre", "width=420,height=320,resizable=no,scrollbars=no,status=no,toolbar=no,directories=no,menubar=no,location=no");

   pre.focus();

}



function validCVV(cvv){

  MyRe = /\d{3}$/gi;

  if (!MyRe.exec(cvv)){

    return false;

  }

  return true;

}

  



function submitIt2_payment() {

  if ( IsEmpty(document.main.name.value) ) {

    alert("Name cannot be empty");

    document.main.name.focus();

    return false;

  }

  if ( IsEmpty(document.main.address.value) ) {

    alert("Address cannot be empty");

    document.main.address.focus();

    return false;

  }

  if ( IsEmpty(document.main.postcode.value) ) {

    alert("PostCode cannot be empty");

    document.main.postcode.focus();

    return false;

  }

  if ( IsEmpty(document.main.tel.value) ) {

    alert("Phone cannot be empty");

    document.main.tel.focus();

    return false;

  }

  if (!validEmail(document.main.email.value)) {

    alert("Invalid email address");

    document.main.email.focus();

    document.main.email.select();

    return false;

  }

  if (!validCVV(document.main.cvv.value)) {

    alert("Invalid CVV");

    document.main.cvv.focus();

    return false;

  }

/*  if ( IsEmpty(document.main.cc.value) ) {

    alert("Card Number cannot be empty");

    document.main.cc.focus();

    return false;

  }

*/

  if ( !CheckCardNumberFull(document.main.cc, document.main.cct, document.main.expyear, document.main.expmonth) ) {

//    alert("Expiration Year cannot be empty");

//    main.expyear.focus();

    return false;

  }

}



function CheckFields_tellfriend() {

    if(!document.main.name.value) {

        alert("Enter Your Name!");

        return false;

    }

    if(!document.main.email.value) {

        alert("Enter Your Email!");

        return false;

    }

    if(!document.main.email1.value && !document.main.email2.value 

    && !document.main.email3.value && !document.main.email4.value

    && !document.main.email5.value) {

        alert("Enter Friend Email!");

        return false;

    }

    if(!document.main.standard.value 

    && document.main.type_message.value == 'standard') {

        alert("Enter Standard Message!");

        return false;

    }

    if(!document.main.custom.value 

    && document.main.type_message.value == 'custom') {

        alert("Enter Custom Message!");

        return false;

    }



    return true;

}



function CheckFields_email() {

    if(!document.main.email.value) {

        alert("Enter Your Email!");

        return false;

    }

    if(!document.main.msg.value) {

        alert("Enter Your Message!");

        return false;

    }



    return true;

}



function validAnswer() {

  if (main.answer.value == "") {

    alert("Please enter your answer!");

    document.main.answer.focus();

    return false;

  }

  return true;

}



function getaccountinf() {

   document.main.action.value="account";

   document.main.submit();

   return true;

}





function getcontactinf() {

   document.main.action.value="contact";

   document.main.submit();

}





function getbillinginf() {

   document.main.action.value="billing";

   document.main.submit();

}





function setmailtoactiveinf() {

   document.main.action.value="mailtoactive";

   document.main.submit();

}



function popup2(m, w, h) {

   var scroll = 'no';

   var settings;

   var LeftPosition;

   var TopPosition;

   var win;



   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;

   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;



   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;

   settings = settings + ',resizable=no,maximize=no,status=no,toolbar=no,directories=no,menubar=no,location=no';



   win = window.open(m, 'pre', settings);

   win.name = 'name';

   win.focus();

}



/*

function doRotate(name) {



      if (window.XMLHttpRequest) {

         req = new XMLHttpRequest();

      }

      else if (window.ActiveXObject) {

         req = new ActiveXObject("Microsoft.XMLHTTP");

      }



      // request countries.cfm passing searchString as an URL parameter

      req.open("GET", 'http://www.w3rez.com/image_rotate.php?act=get_new_image&name=' + name, true);

      req.send(null);

      // gives the request object an event handler

      req.onreadystatechange = function() {

         if ((req.readyState == 4) && (req.status == 200)) {

            

            if (req.responseText.length>0) {

              var new_name = req.responseText;

                     

              document.getElementById('rotate_image').src= new_name ;

              window.setTimeout('doRotate("'+new_name+'")',5000); 

            }

         }

      }

      

   return;

}  

*/





function doRotateImage(){

   new_time =new Date();



   document.getElementById('rotate_image').src= "http://www.w3rez.com/image_rotate.php?t="+new_time.getTime();

}



function doRotate() {

    

   if (window.XMLHttpRequest) {

      req = new XMLHttpRequest(); 

   }

   else if (window.ActiveXObject) {  

      req = new ActiveXObject("Msxml2.XMLHTTP");



      if(! req){

        req = new ActiveXObject("Microsoft.XMLHTTP"); 

      }

      

   } 

   if(req){  


      /*
      req.onreadystatechange = function() {



         if (req.readyState == 4 || req.readyState=="complete") {

                  

              var new_name = req.responseText;

                    

              document.getElementById('top_link').innerHTML = new_name ;

         }

      }



      var url="text_rotate.php";

      url=url+"?d="+Math.random();



      req.open("GET", url, true);

      req.send(null);

      */

   } 

     tes = document.getElementById('rotate_image');

     

   if(tes){

      doRotateImage();

   }



   window.setTimeout('doRotate()',10000); 





}



function fGenerateBehaviouralLinks() {

    var sHTML = '';

    for(var i=0;i<aBehaviouralCategories.length;i++){

        sHTML += '<div id="behavioural-' + (i+1) + '" class="tools-06c dark-tab" onmouseover="javascript:fSimulateBehaviouralTab(this.id);" onfocus="javascript:fSimulateBehaviouralTab(this.id);" onmouseout="javascript:fClearBehaviouralTab(this.id);" onblur="javascript:fClearBehaviouralTab(this.id);" onclick="javascript:fShowHideBehaviouralCategory(this.id);fSelectBehaviouralTab(this.id);" onkeypress="javascript:fShowHideBehaviouralCategory(this.id);fSelectBehaviouralTab(this.id);">' + aBehaviouralCategories[i] + '</div>';

        

    }

    document.getElementById('behavioural-links').innerHTML = sHTML;

}



// -----------------------

// FUNCTION: fShowHideElement

// DESCRIPTION: A function shows or hides an element.

// ARGUMENTS: sElemendId

// RETURN: None

// -----------------------

function fShowHideElement(sElemendId) {   

    var eElement = document.getElementById(sElemendId);

    var sClassName = eElement.className;



    if (sClassName.match(' access-text') || sClassName.match('access-text')) {

        // Shows element     

        eElement.className = eElement.className.replace(/access-text/, '');

    } else {

        // Hides element

        eElement.className = sClassName + ' access-text';

    }

}



// -----------------------

// FUNCTION: fShowHideBehaviouralCategory

// DESCRIPTION: A function that shows or hides the behavioural categories.

// ARGUMENTS: sElementId

// RETURN: None

// -----------------------

function fShowHideBehaviouralCategory(sElementId) {

    var sClassName = document.getElementById(sElementId).className;

                            

    if(sClassName.match('selected')){  

        return;

    } else {

        if(sElementId != sSelectedBehavioural){

            fShowHideElement(sSelectedBehavioural + '-content');

        }

        fShowHideElement(sElementId + '-content');

        sSelectedBehavioural = sElementId;

        fSelectBehaviouralTab(sElementId);

    }

}



function fSimulateBehaviouralTab(sElementId){

    if(sSelectedBehaviouralTab != sElementId){

        document.getElementById(sElementId).className = 'tools-06c dark-tab-simulated';

    }

}

// -----------------------

// FUNCTION: fClearBehaviouralTab

// DESCRIPTION: A function that simulates a tab off effect for behavioural categories tabs.

// ARGUMENTS: sElementId

// RETURN: None

// -----------------------

function fClearBehaviouralTab(sElementId){

    if(sSelectedBehaviouralTab != sElementId){

        document.getElementById(sElementId).className = 'tools-06c dark-tab';

    }

}

// -----------------------

// FUNCTION: fSelectBehaviouralTab

// DESCRIPTION: A function that simulates a tab selected effect for behavioural categories tabs.

// ARGUMENTS: sElementId

// RETURN: None

// -----------------------

function fSelectBehaviouralTab(sElementId){  

    if(sSelectedBehaviouralTab != ''){

        document.getElementById(sSelectedBehaviouralTab).className = 'tools-06c dark-tab';

    }

    document.getElementById(sElementId).className = 'tools-no-color dark-tab-selected';

    // assign selected tab to gloabal variable

    sSelectedBehaviouralTab = sElementId;

}





startList = function() {

    if (document.all&&document.getElementById) {

        navRoot = document.getElementById("nav");

        for (i=0; i<navRoot.childNodes.length; i++) {

            node = navRoot.childNodes[i];

            if (node.nodeName=="LI") {

                node.onmouseover=function() {

                    this.className+=" over";

                }

                node.onmouseout=function() {

                    this.className=this.className.replace(" over", "");

                }

            }

        }

    }

}

function openTrackingPopup(PID){
        
        var sURL, sDesrc;
        var sParams = new Array(6);
        sParams[0] = "600"; // ширина окна в пикселях
        sParams[1] = "600"; // высота окна в пикселях
        var x = (screen.availWidth-sParams[0])*0.5-50;
        var y = (screen.availHeight-sParams[1])*0.5;
    
        sURL = "tracking_popup.php?pid=" + PID;
        
        sParams[2] = "yes"; // наличие статус строки
        sParams[3] = "yes"; // наличие кнопок (toolbar)
        sParams[4] = "yes"; // наличие меню
        sParams[5] = "yes"; // наличие скроллингов
        sDesrc = "width=" + sParams[0] + ", height=" + sParams[1] +
        ", status=" + sParams[2] + ", toolbar=" + sParams[3] +
        ", menubar=" + sParams[4] + ", scrollbars=" + sParams[5] +
        ', left=' + x + ', top=' + y;
        window.open(sURL, "displayWindow", sDesrc);
}

window.onload=startList;


function add_article_text(main, tag) {
    var str = '';

    str = str + "<div color=\"#FFFFFF\" width=\"100%\"><table width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">  <tr> <td class=\"mtext\">";

    str = str + "<br><h2>"+document.main.title.value+"</h2>";

    str = str + "<h2>"+document.main.description.value+"</h2>";

    prebody = '';

    if(main.point.value > "") { 

        if(tag!=0) tag += " OfficialWire"; else tag = "OfficialWire";

        prebody =  "Published on " + months[document.main.distrdatemm.value*1] + " " + main.distrdatedd.value + ", 20" +  document.main.distrdateyy.value + "<br>  " 
                   + "<br>(" + tag + ")<br><br>" + document.main.point.value + "<br>";
    }

    str = str + prebody + tinyMCE.get('id_body').getContent();
        
    str = str + "</td></tr><tr><td  class=\"mtext\">"+"<br><hr><br>";

    str = str + "</td></tr></table></div>";
    
    document.getElementById("dialog").innerHTML = str;          
   
    return false;
};

$(function(){
        $('#small,#large').click(function(){
             if(this.id == 'large') {
                jQuery('p,h1,h2,h3,h4,h5,td,a').each(function(){
                    var oldf = parseInt( jQuery(this).css('font-size') );
                    var oldl = parseInt( jQuery(this).css('line-height') );
                    jQuery(this).css({
                    'font-size' : oldf + 2 + 'px',
                    'line-height' : oldl + 0.5 + 'px'
                    });
                }); 
                
            }
            else if (this.id == 'small'){
                jQuery('p,h1,h2,h3,h4,h5,td,a').each(function(){
                    var oldf = parseFloat( jQuery(this).css('font-size') );
                    var oldl = parseFloat( jQuery(this).css('line-height') );
                    jQuery(this).css({
                    'font-size' : oldf - 2 + 'px',
                    'line-height' : oldl - 0.5 + 'px'
                    });
                });
            }
            /*
            var ourText = $('body');
            var currFontSize = ourText.css('fontSize');
            var finalNum = parseFloat(currFontSize, 10);
            var stringEnding = currFontSize.slice(-2);
            if(this.id == 'large') {
                finalNum *= 1.2;
            }
            else if (this.id == 'small'){
                finalNum /=1.2;
            }
            ourText.css('font-size', finalNum + stringEnding);
            
            var ourText1 = $('#td1');
            var currFontSize = ourText.css('fontSize');
            alert(currFontSize);
            var finalNum = parseFloat(currFontSize, 10);
            var stringEnding = currFontSize.slice(-2);
            ourText.css('font-size', finalNum + stringEnding);
            
            */
            
            /*
            var currentFontSize = $('html').css('font-size');
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            
            if(this.id == 'large') {
                var newFontSize = currentFontSizeNum*1.2;
            }
            else if (this.id == 'small'){
                var newFontSize = currentFontSizeNum*0.8;
            }           
            
            $("html").css({fontSize : newFontSize});
            */
        });
    });


function showSlidingDiv(id){
    var name = "#win_"+id;
    $(name).animate({"height": "toggle"}, { duration: 1000 });
}    