// JavaScript Document dtdft
var $j = jQuery.noConflict(), c_Fullpat = '', c_currPath = '', get_bloginfo = new Array(), global_ready = false, c_Stat = true;
$j(document).ready(function(){	
	(document.getElementById('c_dialog'))?'':$j('body').prepend('<div id="c_dialog" style="background-color:#fffff;"></div>');
	
	$j('ul li:first-child').addClass('first');
	$j('ul li:last-child').addClass('last');
	
	$j('tr:first-child').addClass('first');
	$j('tr:last-child').addClass('last');
	
	$j('td:first-child').addClass('first');
	$j('td:last-child').addClass('last');

	adoncrej();
		

	$j('link').each(function(){
		if($j(this).attr('rel') == 'index')c_Fullpat = $j(this).attr('href')+'/'; 
		if($j(this).attr('rel') == 'canonical')c_currPath = $j(this).attr('href')+'/';
	});
	
	$j( "input:button, .submit_ajax").button();
	c_tabberS();	
	
	
	query='c_action=c_bloginfo';		
	$j.get(c_Fullpat, query, function(data){
		//get_bloginfo = data;
		var s =data;
		s = s.split(',');
		for(q=0;q<=s.length;q++){			
			if(s[q]){
				var r = s[q];
				r = r.split('|||');
				get_bloginfo[r[0]] = r[1]; 
			}
		}		
		c_global_Loader();
		global_ready = true;
		
		
		var getscript = get_bloginfo['getscript'];
 		getscript = getscript.split('|');
		for(r=0;r<=getscript.length;r++){
			if(getscript[r]){
				if(getscript[r].length>2){
					//alert(get_bloginfo['template_url']+'/modules/'+getscript[r]);
					$j.getScript(get_bloginfo['template_url']+'/modules/'+getscript[r], function(data, textStatus){
					});
				}
			}
		}
		
	});
	
	
});

function c_global_Loader(){
	
}


function c_tabberS(){	
	$j(".c_accordion").accordion({
		autoHeight: false,
		navigation: true,
		collapsible: true
	});
	
	$j(".tabs").tabs({
		collapsible: true
	});
	/*
	
	$j(".tabs ul").each(function(){	
		var p = $j(this);
		setTimeout(function(){			
			p.children("li").first().children('a').click();
		}, 500);
	});	*/
}


function c_EmailStat(o){	
	var email = o.val();
	var passed;
	var blnRetval, intAtSign, intDot, intComma, intSpace, intLastDot, intDomain, intStrLen;
	intAtSign=email.indexOf("@");
	intDot=email.indexOf(".",intAtSign);
	intComma=email.indexOf(",");
	intSpace=email.indexOf(" ");
	intLastDot=email.lastIndexOf(".");
	intDomain=intDot-intAtSign;
	intStrLen=email.length;
	// *** CHECK FOR BLANK EMAIL VALUE
	
	if (intAtSign == -1){
		c_default_error_box(o);
	}else if (intComma != -1){
		c_default_error_box(o);
	}else if (intSpace != -1){
		c_default_error_box(o);
	}else if ((intDot <= 2) || (intDomain <= 1)  || (intStrLen-(intLastDot+1) < 2)){
		c_default_error_box(o);
	}
};



function c_EmptyStat(o){
	if(o.val() == '' || o.val() == o.attr('title')){
		c_default_error_box(o);
	}
}

function c_default_error_box(obj){
	c_Stat = false;
	$j(obj).css({
		'background-color':'#ffece5',	
		'border':'#be0108 1px solid',
		'background-image':'url('+get_bloginfo['template_url']+'images/fields_error.png)',
		'background-repeat':'no-repeat',
		'background-position':'top right'	
	});
}

function c_scroll_anywhere(setheight){

	$j.fn.extend({
		autoscroll: function(options) {
			return this.each(function() {
				var $this = $j(this);
				$this.css({overflow:'hidden'});
				if(options.direction == 'horizontal') $this.mousemove(function(e) {
					var width = $this.width();
					$this.attr({ scrollLeft: ($this.attr('scrollWidth')-width)*(0.5-Math.cos(Math.PI*(e.pageX-$this.offset().left)/width)/2) });
				});
				else if(options.direction == 'vertical') $this.mousemove(function(e) {
					var height = $this.height();
					$this.attr({ scrollTop: ($this.attr('scrollHeight')-height)*(0.5-Math.cos(Math.PI*(e.pageY-$this.offset().top)/height)/2) });
				});
				else $this.mousemove(function(e) {
					var width = $this.width(), height = $this.height();
					$this.attr({ scrollLeft: ($this.attr('scrollWidth')-width)*(0.5-Math.cos(Math.PI*(e.pageX-$this.offset().left)/width)/2), scrollTop: ($this.attr('scrollHeight')-height)*(0.5-Math.cos(Math.PI*(e.pageY-$this.offset().top)/height)/2) });
				});
			});
		}
	});
	$j('html, body').animate({scrollTop: setheight}, "fast", 'linear');
}

/*addedd of jho*/
function adoncrej() { 
	$j('#topnavContIn .menu ul').addClass('clearfix');
	$j('#fcont .menu ul').attr('id', 'fnav');	 
	$j('input[type=submit]').addClass('submit');
	$j('.fmenu li ul').remove();
	

	$j('input[name=captchaj]').each(function(){
		$j(this).attr('title', 'Anti-Spam Code');//Type
		$j(this).addClass('watermark_label'); 
	});

	/*Removing Settings page in any menu*/
	$j('li a').each(function(){
		var s = $j(this);
		var settings = s.html();
		if(settings == 'settings'){
			s.parent().css('display', 'none');
		}
	});	


	/*-CONTACT FORM 7 NOTIFICATION-*/
	$j('div.wpcf7-response-output').unbind('mouseenter').mouseenter(function(){
		$j(this).animate({
			'opacity': 0
		}, 5000, function(){
			$j(this).css({
				'display': 'none'
			});
		});
	}).unbind('mouseleave').mouseleave(function(){
		$j(this).animate({
			'opacity': ''
		}, 2000, function(){
			$j(this).css({
				'display': ''
			});
		});
	});
	
	
	 // footer Menu
	var divUlData = '';	
	$j('.fmenu li').each(function(){
		divUlData += ' | ' + $j(this).html();
	});
	divUlData = divUlData.substring(2, divUlData.length);		
	$j('.fmenu').html( divUlData);

	//.wpcf7 height
	$j('.wpcf7').each(function(){
		var cf7 = $j(this);
		var h = cf7.height();
		var w = cf7.width();
		var o = cf7.children().children('.wpcf7-response-output');
		o.css({
			'height': h - 22,
			'width': w - 22
		});
	});
	 
	/*-----------------widget tabber-------------------------*/
	$j('.tabberj h2').each(function() {
		var h = $j(this);
		//var i = parseInt(h.length);
		var p = h.parent().attr('id');
		 $j('.tabberj ul.tbrmenu').append('<li><a href="#'+p+'">'+h.html()+'</a></li>');
	});	
	//$j("#tabs").tabs();
	$j('.tabberj h2').remove();
	
	/*-------------------Form In Label-------------------------------*/
	$j('form').each(function(i, n){
		$j(n).find('.watermark_label').each(function(i, n) {
			var input = $j(n);
			input.val(input.attr('title'));
			input.addClass('inlabel');
	
			input.focus(function() {
				if ($j(this).hasClass('inlabel'))
					$j(this).val('').removeClass('inlabel');
			});	
	
			input.blur(function() {
				if ($j(this).val() == '')
					$j(this).val($j(this).attr('title')).addClass('inlabel');
			});
		});
	});
	
	/*-------------DATE PICKER--------------------*/
	$j('form input[name=date]').each(function(){
		$j(this).datepicker({ 
		  dateFormat: 'MM dd, yy',
		  altFormat: "yy-mm-dd",
		  changeMonth: true,
		  changeYear: true,
		  onSelect: function(dateText, inst) {    
		  }
		 });
	});

	/*---------------TABLE----------------------------*/
	$j('#content table').each(function(){
		var tr = $j(this).children().children();
		var trcount = tr.length;
		var c = 0;
		tr.each(function(){
			c++;
			if(c%2){
				$j(this).addClass('odd row'+c);
			}else{
				$j(this).addClass('even row'+c);
			}
			//TD CLASS
			var td = $j(this).children();
			var tdcount = td.length;
			var tc = 0;
			td.each(function(){
				tc++;
				$j(this).addClass('col'+tc);
			});

		});

		
	});
}
