﻿/* A validation method that validates a valid US number*/
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number");
var scrollposition=0;
var top;
$(document).scroll(function(){
	
	//scrollsimply
	
		$("#scroller").simplyScroll({
			className: 'custom',
			autoMode: 'loop',
			pauseOnHover: true,
			frameRate: 20,
			speed: 3
		});
	

	
	scrollposition=$(this).scrollTop();
	
	
	//alert(scrollposition);
	//alert(top);
	$.cookie("scroll",scrollposition);
	//alert(scrollposition);
	//alert($.cookie("scroll"));
});


$(document).ready(function() {
	//show annuncement
	//$("#ann").slideDown(2500);
	//
	$("#close_ann").click(function(){
		$("#ann").hide(2500).remove();
		return false;
	});
	//remove hide class from international_details
	$(".international_details").delay(1500).slideDown(1500,function(){ return false;});
	//Subscription ajax call
		$('#subscription_email').validate({
				errorPlacement:function(error,element){
				error.appendTo(element.parent('td').find('.custom_error_message'));
			}
		});
	$('#subscription_email').submit(function(){
		//$value=$('input:text[name=sub_email]').val();
		if(!$(this).valid()){
			return false;
		}else{
		$value=$('#sub_email').val();
			//alert("Thanks " + $value);
			$('.sending_message').removeClass('hide');
			$.get('../html/ajax_email.php',{
				email:$value
				},function(data){
					$value=data;
					if($value>0){
					$('.sending_message').addClass('hide');
					$('.message_sent').removeClass('hide');
					$('.subscribe_box').addClass('hide');
					$('.thankyou').removeClass('hide');
					}else{	
						$('.sending_message').addClass('hide');
						alert('Email aready exist');
						$('.subscribe_box').addClass('hide');
						$('.thankyou').removeClass('hide');
						return false;
					}
			});
			return false;
		}
			//return false;
		});
	$("h3").click(function(e){
		$ob =$(this).next('div');
		$id=$(this).next('div').attr('id');
		$title=$ob.attr('title');
		$.get('../html/cop-op_data.php',{id:$id,title:$title},function(data){
		//$ob.html(data);
		});
	$(this).next('div').toggleClass('hide','fast');
	e.preventDefault();
	});	

	$(".inter").hide();
	$(".table_content").addClass('hide');
	
	$(".table_header").click(function(){
		$(this).next(".table_content").toggleClass('hide').animate({ opacity: .7});
		
	}).css("cursor","pointer");
	
});
$(document).ready(function(){
	$("#date").datepicker();
});

  
	$(document).ready(function(){
		
				$('a').click(function(){
					crollposition=$(window).scrollTop();
					//alert(crollposition);
					$(window).scrollTop.value=crollposition;
				//alert(crollposition);
				});
		$('.btn-slide').click(function(){
			$('#panel').slideToggle("slow");
			$(this).toggleClass('active');
			
		});
		$('a.header_name').click(function(){
			$(this).next('.unhide').slideToggle('fast',function(){
				$(this).parent('.course_list').toggleClass('left_align');
				return false;
			});
			return false;
			
		});
			
		
			$(".tabs").tabs();
			
			
			/*$(".header_name").click(function(e){
				var top = document.documentElement.scrollTop;
				//alert(top);
				
				//add a css to move the title to the left of the page
				
				var scroll="'window.scrollTo(";
				var comma=',';
				var endbracket=")',0";
				//alert(scroll+top+comma+top+endbracket);
				
				//scroll page to the current location after postback
				$(window).scrollTo(scrollposition,scrollposition);
				//window.scroll(y,x);
				setTimeout('window.scrollTo('+top+','+top+')',1);
				//setTimeout(scroll+top+comma+top+endbracket);
				$(this).parent('.course_list').toggleClass('left_align');
				e.preventDefault();
			});*/
			
		
	}); 
	
