/* Highlight blue buttons */
function Btn(EVT2)
{
  EVT2.parentNode.className = 'submit_button_hover';
  EVT2.onmouseout = function(){EVT2.parentNode.className = 'submit_button';};
}


/* Send link form */
function Hide_efb2()
{ 
  gebi('efb2').style.display='none';
  gebi('FeedbackOverlay').style.display='none';
}

var BRWSR = navigator.userAgent.toLowerCase();

function ReposFeedbackForm()
{
  if(!gebi('efb2') && !gebi('MainTable') && !gebi('FeedbackOverlay')) {return;}
  if(BRWSR.match('msie')) 
  {gebi('efb2').style.top=(gebi('MainTable').clientHeight-496)+'px';}
  else
  {
    if(BRWSR.match('opera')) 
    {gebi('efb2').style.top=(gebi('MainTable').clientHeight-490)+'px';}
    else
    {gebi('efb2').style.top=(gebi('MainTable').clientHeight-507)+'px';}
  }
  gebi('FeedbackOverlay').style.height=document.body.clientHeight+'px';
  if(document.body.clientWidth < 1000) 
  {
    if(BRWSR.match('msie 6'))
    {gebi('FeedbackOverlay').style.right='-200px';}
    else
    {gebi('FeedbackOverlay').style.right='-'+(1000-document.body.clientWidth)+'px';}
  }
  else
  {
    gebi('FeedbackOverlay').style.right='0px';
  }
  if(BRWSR.match('opera'))
  {
    gebi('FeedbackOverlay').style.height=(gebi('MainTable').clientHeight+150)+'px';
  } 
}



// Failsafe catch if serviceURL is not defined
if ( typeof(serviceURL) == "undefined")
	var serviceURL = 'http://www.cyberplat.com'; 
	

// Failsafe catch in case thisUrl is not defined
var EF_thisUrlNotSet = typeof(thisURL) == "undefined";
if (EF_thisUrlNotSet)
	var thisURL = document.location.protocol + "//" + document.location.hostname + document.location.pathname;

var EF_Required = { // validate in reverse for focus order as onscreen...
	eafmessage:true,
	eafsubject:true,
	eafurl:false,
	eafemail:true,
	eafrecipentemail:true
	};

var EF_Localized = {
		eafhdr:'Email This Page',
		eafsaveerror:'Sorry the system is busy, try again later.',
		eafsent:'Your Email is already sent',
		eafheader:'Email this page to your friend. Complete the form below and click on the "send" button. All fields are required to help prevent spam.',
		eafemail:'Your email address:',
		eafrecipentemail:'Recipients email address:',
		eafsubject:'Subject:',
		eafmessage:'Comments:',
		eafsubmit:'Submit',
		eafclose:'Close',
		eaflengthTooLong:'(Message too long please shorten)',
		eaftotallen:1900
	};

var EF_T = function(t){return EF_Localized[t]||t;}

//run after page is entirely done loading
$(document).ready(function() 
{
  $(document.body).prepend('<div id="FeedbackOverlay" onClick="Hide_efb2();"></div>');
  $(document.body).prepend(
			  '<div class="FloatWindow" id="efb2">'
			+ '	<div class="EFin_399px" >'
			+ '	<table class="FTab" cellpadding="0" cellspacing="0">'
			+ '	<tr><td class="FHeadL">&nbsp;&nbsp;<b>' + EF_T('eafhdr') + '</b></td><td class="FHeadR"><a href="JavaScript:Hide_efb2();" style="color:#fff;">' + EF_T('eafclose') + '</a>&nbsp;&nbsp;</td></tr>'
			+ '	<tr><td colspan="2" class="FBodyM">'
			+ '		<div id="EF_LenError" class="EF_MsgLenError"></div>'
			+ '		<div>' + EF_T('eafheader') + '</div><br /><br />'
			+ '		<div>' + EF_T('eafrecipentemail') + '</div><input type="text" size="40" maxlength="255" id="eafrecipentemail"><br><br>'
			+ '		<div>' + EF_T('eafemail') + '</div><input type="text" size="40" maxlength="255" id="eafemail"><br /><br />'
			+ '		<div>' + EF_T('eafsubject') + '</div><input type="text" size="40" maxlength="255" id="eafsubject"><br /><br />'
			+ '		<div>' + EF_T('eafmessage') + '</div><TEXTAREA id="eafmessage" rows="6"></TEXTAREA>'
			+ '		<input type="button" id="FeedbackSendButton" class="groovybutton" onclick="javascript:processEAF();" value="' + EF_T('eafsubmit') + '"><input type="hidden" id="eafurl">'
			+ '	</td><tr>'
			+ '	</table>'
			+ '	</div>'
			+ '</div>'
  );
  $('#EF_LenError').html(EF_T('eaflengthTooLong'));
  $('#EF_LenError').hide();
});

function eaf(eafTitle, eafURL)
{
  ReposFeedbackForm();
  gebi('FeedbackSendButton').disabled=false;
  gebi('FeedbackOverlay').style.display='block';
	$("#eafsubject").val(document.title);
	$("#eafurl").val(thisURL);
  gebi('FeedbackOverlay').style.display='block';
  gebi('efb2').style.display='block';
}

function processEAF()
{
  gebi('FeedbackSendButton').disabled = true;
  var err;
	for (var j in EF_Required) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if ( ( (j == "eafemail" || j == "eafrecipentemail") && !isValidEmail($("#" + j).val())) || (EF_Required[j] && $('#' + j).val() == "")) {
			err = j;
			$('#' + j).prev().append('<font id=' + j + 'err' + ' color=red>*</font>');gebi('FeedbackSendButton').disabled = false;
		}

	}

	var sendQS = "";
	sendQS += ("&msg=" + encodeURIComponent($('#eafmessage').val()));
	sendQS += ("&subj=" + encodeURIComponent($('#eafsubject').val()));
	sendQS += ("&url=" + encodeURIComponent($('#eafurl').val()));
	sendQS += ("&sender=" + encodeURIComponent($('#eafemail').val()));
	sendQS += ("&recipient=" + encodeURIComponent($('#eafrecipentemail').val()));

	if (err!=null) $('#' + err).focus();
	if (sendQS.length>EF_T('eaftotallen')) { err=true; $('#EF_LenError').show(); }
	if (err!=null) {gebi('FeedbackSendButton').disabled = false;return;}

	jQuery.get('/sender.php?cmd=send', {'msg': encodeURIComponent($('#eafmessage').val()), 'subj': encodeURIComponent($('#eafsubject').val()),'url': encodeURIComponent($('#eafurl').val()), 'sender': encodeURIComponent($('#eafemail').val()),'recipient': encodeURIComponent($('#eafrecipentemail').val())}, 
	function(data)
  {
		gebi('FeedbackOverlay').style.display='none';
		gebi('efb2').style.display='none';
  }
 );
}

function processEAFCallback(eafDataSaved)
{
	if ( !eafDataSaved)
		alert(EF_T('eafsaveerror'));
	else
	{
		alert(EF_T('eafsent'));
		$("#efb2").jqmHide();
	}
}

function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
/* END OF Send link form */




/* Send Comment form */
// Failsafe catch if serviceURL is not defined
if ( typeof(serviceURL) == "undefined")
	var serviceURL = 'http://tmp.cyberplat.com'; 
	
// Failsafe catch in case thisUrl is not defined
var FB_thisUrlNotSet = typeof(thisURL) == "undefined";
if (FB_thisUrlNotSet)
	var thisURL = document.location.protocol + "//" + document.location.hostname + document.location.pathname;

var FB_Required = { // validate in reverse for focus order as onscreen...
	fmessage:true,
	ftitle:false,
	furl:false,
	femail:true};

var FB_Localized = {
		feedbackhdr:'Feedback For This Page',
		feedbacksaveerror:'Sorry the system is busy, try again later.',
		feedbacksent:'Feedback Sent',
		feedbackemail:'Your email address:',
		feedbackmessage:'Message:',
		feedbacksubmit:'Submit',
		feedbackclose:'Close',
		feedbacklengthTooLong:'(Feedback too long please shorten)',
		feedbacktotallen:1900
	};
var FB_T = function(t){return FB_Localized[t]||t;}

function Hide_fb2()
{ 
  gebi('fb2').style.display='none';
  gebi('CommentOverlay').style.display='none';
}

function ReposCommentForm()
{
  if(!gebi('fb2') && !gebi('MainTable') && !gebi('CommentOverlay')) {return;}
  if(BRWSR.match('msie')) 
  {gebi('fb2').style.top=(gebi('MainTable').clientHeight-328)+'px';}
  else
  {
    if(BRWSR.match('opera'))
    {gebi('fb2').style.top=(gebi('MainTable').clientHeight-326)+'px';}
    else
    {gebi('fb2').style.top=(gebi('MainTable').clientHeight-344)+'px';}
  }
  gebi('CommentOverlay').style.height=document.body.clientHeight+'px';
  if(document.body.clientWidth < 1000) 
  {
    if(BRWSR.match('msie 6'))
    {gebi('CommentOverlay').style.right='-200px';}
    else
    {gebi('CommentOverlay').style.right='-'+(1000-document.body.clientWidth)+'px';}
  }
  else
  {
    gebi('CommentOverlay').style.right='0px';
  }
  if(BRWSR.match('opera'))
  {
    gebi('CommentOverlay').style.height=(gebi('MainTable').clientHeight+150)+'px';
  } 
}


// run after page is entirely done loading
$(document).ready(function() 
{
  $(document.body).prepend('<div id="CommentOverlay" onClick="Hide_fb2();"></div>');
	$(document.body).prepend(
			  '<div class="FloatWindow2" id="fb2">'
			+ '	<div class="FWin" >'
			+ '	<table class="FTab" cellpadding="0" cellspacing="0">'
			+ '	<tr><td class="FHeadL">&nbsp;&nbsp;<b>' + FB_T('feedbackhdr') + '</b></td><td class="FHeadR"><a href="JavaScript:Hide_fb2();" style="color:#fff;">' + FB_T('feedbackclose') + '</a>&nbsp;&nbsp;</td></tr>'
			+ '	<tr><td colspan="2" class="FBody">'
			+ '		<div id="FB_LenError" class="FB_MsgLenError"></div>'
			+ '		<div>' + FB_T('feedbackemail') + '</div><input type="text" size="40" maxlength="255" id="femail"><input type="hidden" id="ftitle"><input type="hidden" id="furl"><br /><br />'
			+ '		<div>' + FB_T('feedbackmessage') + '</div><TEXTAREA id="fmessage" rows="6"></TEXTAREA>'
			+ '		<input type="button" class="groovybutton" id="CommentSendButton" onClick="processFeedback();" value="' + FB_T('feedbacksubmit') + '">'
			+ '	</td><tr>'
			+ '	</table>'
			+ '	</div>'
			+ '</div>'
      );
	$('#FB_LenError').html(FB_T('feedbacklengthTooLong'));
	$('#FB_LenError').hide();
});

function sfb(feedbackTitle, feedbackURL)
{
  ReposCommentForm();
  gebi('CommentSendButton').disabled=false;
  gebi('CommentOverlay').style.display='block';
  gebi('fb2').style.display='block';
	$("#ftitle").val(document.title);
	$("#furl").val(thisURL);
}


//User clicked on the Submit Feedback Button
function processFeedback()
{
  gebi('CommentSendButton').disabled = true;
	var err;
	for (var j in FB_Required) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if ( (j == "femail" && !isValidEmail($("#femail").val())) || (FB_Required[j] && $('#' + j).val() == "")) {
			err = j;
			$('#' + j).prev().append('<font id=' + j + 'err' + ' color=red>*</font>');gebi('CommentSendButton').disabled = false;
		}
	}

	var sendQS = "";
	sendQS += ("&P1=" + escape($('#fmessage').val()));
	sendQS += ("&P2=" + escape($('#ftitle').val()));
	sendQS += ("&P3=" + escape($('#furl').val()));
	sendQS += ("&P4=" + escape($('#femail').val()));

	if (err!=null) $('#' + err).focus();
	if (sendQS.length>FB_T('feedbacktotallen')) { err=true; $('#FB_LenError').show(); }
	if (err!=null) {gebi('CommentSendButton').disabled = false;return;}

	//getData(serviceURL + "/isn/home/CommonServices.ashx?F=ProcessFeedback" + sendQS);
	jQuery.get('/sender.php?cmd=feedback', {'msg': encodeURIComponent($('#fmessage').val()), 'title': encodeURIComponent($('#ftitle').val()),'url': escape($('#furl').val()), 'email': escape($('#femail').val())}, 
	function(data)
{
    // worked and saved
		$("#fmessage").val("");
		Hide_fb2();
}
);
}	


function processFeedbackCallback(fbDataSaved)
{
	if ( !fbDataSaved)
		alert(FB_T('feedbacksaveerror'));
	else
	{
		alert(FB_T('feedbacksent')); // worked and saved
		$("#fmessage").val("");
		Hide_fb2();
	}
}

/* END OF Send Comment form */




/* For both Send Comment AND Send link forms */
window.onresize = ReposFloatForms;
function ReposFloatForms()
{
  ReposFeedbackForm();
  ReposCommentForm();
}


function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function isntNullEmail(str) {
	return (str.length>0);
}
/* END OF For both Send Comment AND Send link forms */



/* Subscribe */
function subscribe(){
  var VarEmail = gebi('email').value; //for detailed e-mail address check
  if (!/^[a-z0-9_\-\.]+?@[a-z0-9_\-\.]+?\.[a-z]{2,4}$/i.test(VarEmail))
  {
    $("table#subscribeTAB span").hide(); 
	  gebi('if_emal_fail_det').style.display='block';
    return;
  }
  $("table#subscribeTAB span").hide();
  gebi('EFcontainer').innerHTML = '<table class="EFbutton" style="width:6.3em" cellspacing="0" cellpadding="0"><tr><td>Subscribe<\/td><\/tr><\/table>';
  gebi('EFcontainer').className = 'submit_button_disabled';

jQuery.get('/sender.php?cmd=subscribe', 
{'mail': escape($('#email').val())});
location.href='/subscribe/'; 
}

var FB_Submit_Req= {//validate in reverse for focus order as onscreen...
	post_text:false,
	phone:false,
	email:true,
	location:false,
	company:false,
	occupation:false,
	name_surname:true};

function fb_submit()
{
  var VarEmail = gebi('email').value; //for detailed e-mail address check
  var err;
  
	for (var j in FB_Submit_Req) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if (FB_Submit_Req[j] && $('#' + j).val() == "") {
			err = j;
		}
	}
	
	if (err!=null) {
	$('#' + err).focus(); 
	if(err=='name_surname') {
	$("div#fb_form span").hide();
	$('p#err_'+err).append('<span class="err_info" style="color:#b00;display:block;">Please, enter your name</span>');
	}
	
	if(err=='email'){ 
	$("div#fb_form span").hide();
	gebi('if_emal_fail').style.display='block';
	}
	}

	if (err!=null) return;
	
	if (!/^[a-z0-9_\-\.]+?@[a-z0-9_\-\.]+?\.[a-z]{2,4}$/i.test(VarEmail))
  {
    $("div#fb_form span").hide();
    gebi('if_emal_fail_det').style.display='block';
    return;
  }

$("div#fb_form span").hide();
gebi('EFcontainer').innerHTML = '<table class="EFbutton" style="width:5.5em" cellspacing="0" cellpadding="0"><tr><td>Sumbit<\/td><\/tr><\/table>';
gebi('EFcontainer').className = 'submit_button_disabled';

//check jQuery support
gebi('fb_form').style.position = 'static';
$("div#fb_form").css('position','relative'); 
if (gebi('fb_form').style.position == 'relative') {} else {alert('JavaScript error');return;}
//end check jQuery support

jQuery.post('/sender.php?cmd=post_feedback', 
{'name_surname': encodeURIComponent($('#name_surname').val()),
'occupation': encodeURIComponent($('#occupation').val()),
'company': encodeURIComponent($('#company').val()),
'location': encodeURIComponent($('#location').val()),
'email': escape($('#email').val()),
'phone': encodeURIComponent($('#phone').val()),
'post_text': encodeURIComponent($('#post_text').val())

}, function(data){location.href='/contact/feedback/feedback_sent/';});
}


var reg_d_Submit_Req= { // validate in reverse for focus order as onscreen...
	phone:true,
	email:true,
	position:true,
	fullname:true,
	op_country:true,
	fullorg:true
	};

function reg_d_submit(){

var VarEmail = gebi('email').value;  //for detailed e-mail address check
var err;
	
	
	for (var j in reg_d_Submit_Req) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if (reg_d_Submit_Req[j] && $('#' + j).val() == "") {
			err = j;
			
			//$('#' + j).prev().append('<font id=' + j + 'err' + ' color=red>*</font>');
		}
	}
	if (err!=null) {
	$('#' + err).focus(); 
	if(err=='fullname') {
	$("div#reg_d_form span").hide();
	$('p#err_'+err).append('<span class="err_fullname" style="color:#bb0000;display:block;">Please, enter your full name</span>');
	}
	
	if(err=='email'){
  $("div#reg_d_form span").hide(); 
	gebi('if_emal_fail').style.display='block';
	}
	
	if(err=='fullorg'){ 
	$("div#reg_d_form span").hide();
	$('p#err_'+err).append('<span class="err_fullorg" style="color:#bb0000;display:block;">Please, enter the full name of your organization</span>');
	}

	if(err=='op_country'){ 
	$("div#reg_d_form span").hide();
	$('p#err_'+err).append('<span class="err_country" style="color:#bb0000;display:block;">Please, enter the country of operation</span>');
	}
	
	if(err=='position'){ 
	$("div#reg_d_form span").hide();
	$('p#err_'+err).append('<span class="err_position" style="color:#bb0000;display:block;">Please, enter your position</span>');
	}
	
	if(err=='phone'){ 
	$("div#reg_d_form span").hide();
	$('p#err_'+err).append('<span class="err_phone" style="color:#bb0000;display:block;">Please, enter your phone</span>');
	}
	
	}
		
	
	if (err!=null) return;

  if (!/^[a-z0-9_\-\.]+?@[a-z0-9_\-\.]+?\.[a-z]{2,4}$/i.test(VarEmail))
  {
    $("div#reg_d_form span").hide();
    gebi('if_emal_fail_det').style.display='block';
    return;
  }
  $("div#reg_d_form span").hide(); 
  gebi('EFcontainer').innerHTML = '<table class="EFbutton" style="width:5.5em" cellspacing="0" cellpadding="0"><tr><td>Register<\/td><\/tr><\/table>';
  gebi('EFcontainer').className = 'submit_button_disabled';

  //check jQuery support
  gebi('reg_d_form').style.position = 'static';
  $("div#reg_d_form").css('position','relative'); 
  if (gebi('reg_d_form').style.position == 'relative') {} else {alert('JavaScript error');return;}
  //end check jQuery support


  jQuery.post('/sender.php?cmd=reg_dealer', 
  {'fullorg': encodeURIComponent($('#fullorg').val()),
  'op_country': encodeURIComponent($('#op_country').val()),
  'fullname': encodeURIComponent($('#fullname').val()),
  'position': encodeURIComponent($('#position').val()),
  'email': escape($('#email').val()),
  'phone': encodeURIComponent($('#phone').val())
  }, function(data){location.href='/join/dealer/registered/';});
}


var reg_prov_Submit_Req= { // validate in reverse for focus order as onscreen...
	opt7:false,
	opt6:false,
	opt5:false,
	opt4:false,
	opt3:false,
	opt2:false,
	opt1:false,
	phone:true,
	email:true,
	position:true,
	fullname:true,
	op_country:true,
	fullorg:true
	};

function reg_prov_submit(){

var VarEmail = gebi('email').value;  //for detailed e-mail address check
var err;
	
	
	for (var j in reg_prov_Submit_Req) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if (reg_prov_Submit_Req[j] && $('#' + j).val() == "") {
			err = j;
		}
	}
	if (err!=null) {
	$('#' + err).focus();
   
	if(err=='fullname') {
	$("div#reg_prov_form span").hide();
	$('p#err_'+err).append('<span class="err_fullname" style="color:#bb0000;display:block;">Please, enter your full name</span>');
	}
	
	if(err=='email'){
  $("div#reg_prov_form span").hide(); 
	gebi('if_emal_fail').style.display='block';
	}
	
	if(err=='fullorg'){ 
	$("div#reg_prov_form span").hide();
	$('p#err_'+err).append('<span class="err_fullorg" style="color:#bb0000;display:block;">Please, enter the full name of your organization</span>');
	}
	
	if(err=='op_country'){ 
	$("div#reg_prov_form span").hide();
	$('p#err_'+err).append('<span class="err_op_country" style="color:#bb0000;display:block;">Please, enter the country of operation</span>');
	}
	
	if(err=='position'){ 
	$("div#reg_prov_form span").hide();
	$('p#err_'+err).append('<span class="err_position" style="color:#bb0000;display:block;">Please, enter your position</span>');
	}
	
	if(err=='phone'){ 
	$("div#reg_prov_form span").hide();
	$('p#err_'+err).append('<span class="err_phone" style="color:#bb0000;display:block;">Please, enter your phone</span>');
	}
	
	}
	if (err!=null) return;
  
  if (!/^[a-z0-9_\-\.]+?@[a-z0-9_\-\.]+?\.[a-z]{2,4}$/i.test(VarEmail))
  {
    $("div#reg_prov_form span").hide();
    gebi('if_emal_fail_det').style.display='block';
    return;
  }
  $("div#reg_prov_form span").hide(); 
  gebi('EFcontainer').innerHTML = '<table class="EFbutton" style="width:5.5em" cellspacing="0" cellpadding="0"><tr><td>Register<\/td><\/tr><\/table>';
  gebi('EFcontainer').className = 'submit_button_disabled';

  //check jQuery support
  gebi('reg_prov_form').style.position = 'static';
  $("div#reg_prov_form").css('position','relative'); 
  if (gebi('reg_prov_form').style.position == 'relative') {} else {alert('JavaScript error');return;}
  //end check jQuery support

  $("input[@type=checkbox][@checked]").val('on');

  jQuery.post('/sender.php?cmd=reg_prov', 
  {'fullorg': encodeURIComponent($('#fullorg').val()),
  'op_country': encodeURIComponent($('#op_country').val()),
  'fullname': encodeURIComponent($('#fullname').val()),
  'position': encodeURIComponent($('#position').val()),
  'email': escape($('#email').val()),
  'phone': encodeURIComponent($('#phone').val()),
  'opt1': $('#opt1').val(),
  'opt2': $('#opt2').val(),
  'opt3': $('#opt3').val(),
  'opt4': $('#opt4').val(),
  'opt5': $('#opt5').val(),
  'opt6': $('#opt6').val(),
  'opt7': encodeURIComponent($('#opt7').val())
  }, function(data){location.href='/join/provider/registered/';}
);



}


function redir(){
choose = document.getElementById("country");

var url = choose.options[choose.selectedIndex].value;
    if (url) {
        location.href = url;
    }
}

function preview(path,w,h)
    {
	    var pw=window.open("","previewWindow","toolbar=no,location=no,directoties=no,status=no,scrollbars=no,menubar=no,resizable=no,width="+w+",height="+h);
	    pw.document.write("<html><head><title>Fullview</title></head><body leftmargin='0' topmargin='0'>");
	    pw.document.write("<img src='"+path+"' border='0' vspace='0' hspace='0'></body></html>");
    }