﻿function catchEnterSbt(e, type){
	var key=e.keyCode || e.which;
  	if(key == 13){
		if(type == '1'){
			document.searchh.submit();
		}
  	}
}

function stopmove(t, tr){
	clearInterval(t);
	clearInterval(tr);
	//alert($('.bxslider_wrap'));
	
}

function startmove(){
	//alert('a');
//$('.bxslider_wrap').bind();
	easytabs('1', '1');	
	$('ul.foo').bxSlider({
	        alignment: 'vertical',        // 'horizontal', 'vertical' - direction in which slides will move
	        controls: false,                 // determines if default 'next'/'prev' controls are displayed
	        speed: 500,                     // amount of time slide transition lasts (in milliseconds)
	        pager: false,                    // determines if a numeric pager is displayed (1 2 3 4...)
	        pager_short: false,             // determines if a 'short' numeric pager is displayed (1/4)
	        pager_short_separator: ' / ',   // text to be used to separate the short pager
	        margin: 0,                      // if 'horizontal', applies a right margin to each slide, if 'vertical' a
											// bottom margin is applied. example: margin: 50
	        next_text: 'next',              // text to be displayed for the 'next' control
	        next_image: '',                 // image to be used for the 'next' control
	        prev_text: 'prev',              // text to be displayed for the 'prev' control
	        prev_image: '',                 // image to be used for the 'prev' control
	        auto: true,                    // determines if slides will move automatically
	        pause: 3000,                    // time between each slide transition (auto mode only)
	        auto_direction: 'next',         // order in which slides will transition (auto mode only)
	        auto_hover: false,               // determines if slideshow will pause while mouse is hovering over slideshow
	        auto_controls: false,           // determines if 'start'/'stop' controls are displayed (auto mode only)
	        ticker: false,                  // determines if slideshow will behave as a constant ticker
	        ticker_controls: false,         // determines if 'start'/'stop' ticker controls are displayed (ticker mode only)
	        ticker_direction: 'next',       // order in which slides will transition (ticker mode only)
	        ticker_hover: true,             // determines if slideshow will pause while mouse is hovering over slideshow
	        stop_text: 'stop',              // text to be displayed for the 'stop' control
	        start_text: 'start',            // text to be displayed for the 'start' control
			current: 1,
	        wrapper_class: 'bxslider_wrap'  // class name to be used for the outer wrapper of the slideshow
	    });
$('ul.foo_right').bxSlider_r({
	        alignment: 'vertical',        // 'horizontal', 'vertical' - direction in which slides will move
	        controls: false,                 // determines if default 'next'/'prev' controls are displayed
	        speed: 500,                     // amount of time slide transition lasts (in milliseconds)
	        pager: false,                    // determines if a numeric pager is displayed (1 2 3 4...)
	        pager_short: false,             // determines if a 'short' numeric pager is displayed (1/4)
	        pager_short_separator: ' / ',   // text to be used to separate the short pager
	        margin: 20,                      // if 'horizontal', applies a right margin to each slide, if 'vertical' a
	                                        // bottom margin is applied. example: margin: 50
	        next_text: 'next',              // text to be displayed for the 'next' control
	        next_image: '',                 // image to be used for the 'next' control
	        prev_text: 'prev',              // text to be displayed for the 'prev' control
	        prev_image: '',                 // image to be used for the 'prev' control
	        auto: true,                    // determines if slides will move automatically
	        pause: 3000,                    // time between each slide transition (auto mode only)
	        auto_direction: 'next',         // order in which slides will transition (auto mode only)
	        auto_hover: false,               // determines if slideshow will pause while mouse is hovering over slideshow
	        auto_controls: false,           // determines if 'start'/'stop' controls are displayed (auto mode only)
	        ticker: false,                  // determines if slideshow will behave as a constant ticker
	        ticker_controls: false,         // determines if 'start'/'stop' ticker controls are displayed (ticker mode only)
	        ticker_direction: 'next',       // order in which slides will transition (ticker mode only)
	        ticker_hover: true,             // determines if slideshow will pause while mouse is hovering over slideshow
	        stop_text: 'stop',              // text to be displayed for the 'stop' control
	        start_text: 'start',            // text to be displayed for the 'start' control
	        wrapper_class: 'bxslider_wrap1'  // class name to be used for the outer wrapper of the slideshow
	    });


}		
var id_old;
function Show(id, menuid){
	//alert(menuid);
		if(id_old){
			document.getElementById(id_old).style.display = 'none';
		}
		document.getElementById(id).style.display = 'block';
		id_old = id;
		document.getElementById(menuid).style.display = 'none';
}
function DontShow(id, menuid){
		document.getElementById(id).style.display = 'none';
		//document.getElementById(menuid).style.display = 'block';
}
$(function() {
			var validcap = '0';		
			var your_name = $("#your_name");
			from_mail = $("#from_mail");
			friend_name = $("#friend_name");
			to_mail = $("#to_mail");
			captcha_code = $("#captcha_code");
			message = $("#message");
			lang = $("#lang");
			//coment = $("#coment")
			allFields = $([]).add(your_name).add(from_mail).add(friend_name).add(to_mail).add(captcha_code).add(message);
			tips = $("#validateTips");

		//function updateTips(t) {
//			tips.text(t).effect("highlight",{},1500);
//		}

function checkLength(o,min) {
			//alert(o.val().length);
			if (o.val().length <= min ) {
				o.addClass('sendcv_err_ui');
				//updateTips(validname_length + n + validname_must+min+validname_char);
				return false;
			} else {
				return true;
			}

		}

		function checkRegexp(o,regexp,n) {

			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass('sendcv_err_ui');
				//updateTips(n);
				return false;
			} else {
				return true;
			}

		}
		
		function checkCaptch(o) {
					var bValid = true;
					allFields.removeClass('sendcv_err_ui');

					bValid = bValid && checkLength(your_name,0);
					bValid = bValid && checkLength(from_mail,0);
					bValid = bValid && checkLength(friend_name,0);
					bValid = bValid && checkLength(to_mail,0);
					bValid = bValid && checkRegexp(from_mail,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
					bValid = bValid && checkRegexp(to_mail,/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,"eg. ui@jquery.com");
					
			 $.ajax({
				   type: "POST",
				   url: my_url + "templates/captch_ajax.php",
				   data: "captcha_code="+ captcha_code.val(),
				   success: function(msg){
					 // alert(msg);
					if(msg=='1'){
						var imgnew = new Image();
						imgnew.src = my_url + 'templates/captcha.php?' + Date();
						document.getElementById('cpt_img').src = imgnew.src;
						//alert('aa');
						validcap = '0';
						o.addClass('captch_err');
						 //var bValid = true;
						// return false;
					}else if(msg=='0'){
						
						//alert('s');
						validcap = '1';
						o.removeClass('captch_err');
						//alert(bValid);
						if (bValid) {
						var thejobid = window.jobid;
						
						 $.ajax({
							   type: "POST",
							   url: my_url + "templates/ajax.php",
							   data: "your_name="+ your_name.val() + "&from_mail="+ from_mail.val() + "&lang="+ lang.val() + "&friend_name="+ friend_name.val() + "&to_mail="+ to_mail.val()  + "&message="+ message.val()+ "&id="+ thejobid,
							   success: function(msg){
								  alert(msg);
							   }
							});

						$('.dialog').dialog('close');
					}
						 //return true;
					}
				   }
				});
			// alert(validcap);
			
		}
		$(".dialog").dialog({
			resizable: false,			
					bgiframe: true,
					autoOpen: false,
					width:372,
					height: 669,
					modal: true,

			close: function() {
				allFields.val('').removeClass('sendcv_err_ui');
				allFields.val('').removeClass('captch_err');
			}
		});
		 var ButtonText = send;
		 var Button = close_r;
		 var buttons = {};
 $('#send').click(function() {
					checkCaptch(captcha_code);
								
								});
		 $('#close').click(function() {

			 				$('.dialog').dialog('close');
			 				});
		 //$(".dialog").dialog("option", "buttons", buttons);
		
		

	});
function dialog_open(id){
			//$('#create-user').click(function() {
				// alert(id);
				 var imgnew = new Image();
				  imgnew.src = my_url + 'templates/captcha.php?' + Date();
				  document.getElementById('cpt_img').src = imgnew.src;
				  window.jobid = id;
				$('.dialog').dialog('open');
				
				 
				//$(this).addClass("ui-state-default_active"); 
			//})
}
function show_acc_left(id){
	//alert(id);
	$('#from_left_' + id).fadeSliderToggle()
}

