/************************************************************************************************************************
 Author: Meer Zohaib Meeran Baloch
 Designation: Graphic Designer || HTML Developer || CSS Developer || PHP Developer || FLASH Developer 
 Company: Gaditek Associates
 Date Creation: 02 February 2010
 Last Updated : 02 February 2010
*************************************************************************************************************************/
//All Global Variable Define Here for Different Purpose
var autoplay = new Array();
var active_num = 0;
var active_animation;

//All Mix Event Define Here
function mixEvents(p, t1)
{
	//Search Bar Event
	jQuery('#nav2_srch_box').focus(function(){  if(jQuery(this).val() == 'Search'){jQuery(this).val('');}  });

	//Plan Detail Tabs Event
	jQuery('#tab1, #tab2, #tab3').click(function()
	{  
		jQuery('.tab_act').removeClass();    
		jQuery(this).addClass('tab_act');
		jQuery('#1, #2, #3').css('display','none');
		jQuery('#'+jQuery(this).attr("title")+'').fadeIn(); 
	});
	
	//Intelligent Search Result Events
	jQuery('#int_frm select').change(function()
	{
		//Making Active Drop Downs
		switch(true)
		{
			case jQuery(this).attr("name") == "plat":
				 jQuery('#int_sel2, #int_sel3').removeAttr('disabled');
				 jQuery('#int_sel2, #int_sel3').addClass('int_active');
			break;
			
			case jQuery(this).attr("name") == "app":
				 jQuery('#int_sel4, #int_sel5').removeAttr('disabled');
				 jQuery('#int_sel4, #int_sel5').addClass('int_active');
			break;
		}
		updateSearch(p);
	});
	jQuery('#int_chk input').click(function(){  updateSearch(p);  });
	
	//Top Search | Data Display Events
	/*jQuery('#ser_srch_cat').hover(function()
	{
		jQuery('#ser_srch_cat_box').slideDown(140);
		jQuery('#ser_srch_cat_btn').addClass('ser_srch_cat_act');
		
	},
	function()
	{
		jQuery('#ser_srch_cat_box').css('display', 'none');
		jQuery('#ser_srch_cat_btn').removeClass('ser_srch_cat_act');
	});
	
	jQuery('#ser_srch_cat_box').hover(function()
	{
		jQuery('#ser_srch_cat_box').css('display', 'block');
		jQuery('#ser_srch_cat_btn').addClass('ser_srch_cat_act');
	},
	function()
	{
		jQuery('#ser_srch_cat_box').css('display', 'none');
		jQuery('#ser_srch_cat_btn').removeClass('ser_srch_cat_act');
	});*/

	//Top Search | Data Display Events
	jQuery('#search_top_cat_box').hover(function()
	{
		jQuery('#search_top_cat_cont').slideDown(140);
	},
	function()
	{
		jQuery('#search_top_cat_cont').css('display', 'none');
	});

	jQuery('.nav2_srch_top_cat').click(function()
	{  
		//Saving Cat Num in Form
		jQuery('#search_cat_num').val(jQuery(this).attr('name'));
		
		//Submit Form In Service Page
		jQuery('#search_form_data').submit();
	});
}

//Tool Tip Handler
function tollTipHandler(btn, name, data, sep)
{
	jQuery(""+btn+"").hover(
		function ()
		{  
			var num = jQuery(this).attr(""+data+"").split(""+sep+"");
			jQuery("#"+name+num[1]+"").css('display', 'block');
		}, 
		function ()
		{  
			var num = jQuery(this).attr(""+data+"").split(""+sep+"");
			jQuery("#"+name+num[1]+"").css('display', 'none');
		}
	);
}

//Paraghraph Handler Function
function paragraphHandler(height_min, container_id, button_id, button_class, button_text_1, button_text_2)
{
	var height_cur = jQuery('#'+container_id+'').css('height').split("p");
	var height_1 = parseInt(height_min);
	var height_2 = parseInt(height_cur[0]);
	
	//Comparing Current Data Height
	if(height_2 > height_1)
	{
		//Hidding Extra Text
		jQuery('#'+container_id+'').animate({height: height_1},200, function()
		{
			//Display Read More Button
			jQuery('#'+button_id+'').css('display', 'block');
		});

		//Event Binding Read More Button
		jQuery('#'+button_id+'').toggle
		(
			function()
			{
				jQuery('#'+container_id+'').animate({height:height_2}, 500);
				jQuery('#'+button_id+'').addClass(''+button_class+'').html(button_text_2);
			},
			function()
			{
				jQuery('#'+container_id+'').animate({height:height_1}, 500);
				jQuery('#'+button_id+'').removeClass(''+button_class+'').html(button_text_1);
			}
		);
	}
}

//Slide Content Handler 1 Continuesly Changing Banner
function slideContentHandler_1(active, delay_sec, tot_cont, div_id, slide_num)
{
	//Auto Play | Settings
	var delay_time = parseInt(delay_sec)*1000; //Slide Changing Time Define Here in Seconds
	var slide_act = active; //Active Slide Content Define Here
	var slide_cur = parseInt(active)+1; //Current Slide Content Define Here 

	//Checking Current Slide Number
	if(slide_cur > tot_cont){   slide_cur = 1;   }; 

	//Set Time Out for Call Back
	autoplay[slide_num] = setTimeout(function(){   slideContentHandler_1(slide_cur, delay_sec, tot_cont, div_id, slide_num);   }, delay_time);

	//Display Current Slide
	jQuery('#'+div_id+slide_act+'').css('z-index','0');
	jQuery('#'+div_id+slide_cur+'').css('z-index','1');
	jQuery('#'+div_id+slide_cur+'').fadeIn(1000, function(){  jQuery('#'+div_id+slide_act+'').css('display','none')  });
}

//Slide Content Handler 2 Continuesly Changing Banner With Tab Controller
function slideContentHandler_2(active, delay_sec, tot_cont, id_container, id_tab, tab_class, tab_act_class, slide_num)
{
	//Onload Animation Loading Animation
	slideContentHandler_2_Updator(active, delay_sec, tot_cont, id_container, id_tab, tab_act_class, slide_num, '1')
	
	//Tab Click Event Handler
	jQuery(tab_class).click(function()
	{
		var curr = jQuery(this).attr('name');
		
		//Checking Current Number
		if((active_num != curr) && (active_animation == 0))
		{
			//Clearing Time Out
			clearTimeout(autoplay[slide_num]);
			
			//Displaying Current Banner
			slideContentHandler_2_Updator(curr, delay_sec, tot_cont, id_container, id_tab, tab_act_class, slide_num, '0');
		}
	});
}

function slideContentHandler_2_Updator(active, delay_sec, tot_cont, id_container, id_tab, tab_act_class, slide_num, slide_auto)
{
	//Auto Play | Settings
	active_animation = 1;
	var delay_time = parseInt(delay_sec)*1000; //Slide Changing Time Define Here in Seconds
	var slide_act = active; //Active Slide Content Define Here

	//Checking Current Slide Number
	if(slide_act > tot_cont){   slide_act = 1;   }; 

	//Set Time Out for Call Back
	if(slide_auto == 1)
	{
		autoplay[slide_num] = setTimeout(function()
		{
			slide_act = parseInt(slide_act)+1; //Current Slide Content Define Here 
			slideContentHandler_2_Updator(slide_act, delay_sec, tot_cont, id_container, id_tab, tab_act_class, slide_num, slide_auto);   }, delay_time);
	}

	//Display Current Slide
	jQuery('#'+id_container+active_num+'').css('z-index','0');
	jQuery('#'+id_container+slide_act+'').css('z-index','1');
	jQuery('#'+id_container+slide_act+'').fadeIn(1000, function()
	{   
		jQuery('#'+id_container+active_num+'').css('display','none'); 

		//Updating Active Slide Number
		active_num = slide_act;
		active_animation = 0;  
	});
	
	jQuery('#'+id_tab+active_num+'').removeClass(tab_act_class);
	jQuery('#'+id_tab+slide_act+'').addClass(tab_act_class);
}

//Language Drop Down | Event Binding
function language(p, url)
{
	jQuery('#lang_m a').click(function(){  
		getData1(p+'ajax_content/language.php','?page='+jQuery(this).attr("title")+'', 'langtext', url);
	});
}

//Contact US Page Function
function contactEvent(p, t1, t2, t3, t4, t5, t6)
{
	//All Form Field Define Here
	var cont_fld = '#cont_fld-1, #cont_fld-2, #cont_fld-3, #cont_fld-4, #cont_fld-5, #cont_fld-6';
	
	//All Form Value Define Here
	var cont_val = ['',t1,t2,t3,t4,t5,t6];
	
	//Field Value Change Event
	jQuery(cont_fld).blur(function()
	{  
		if(jQuery(this).val() == '')
		{
			var fld = jQuery(this).attr("id").split("-");
			jQuery(this).val(cont_val[fld[1]]);
			jQuery(this).removeClass('cot-frm-act');
		}
	});
	
	//Field Value Click Event
	jQuery(cont_fld).focus(function()
	{  
		if(jQuery(this).attr('class') != 'cot-frm-act')
		{
			jQuery(this).addClass('cot-frm-act');  jQuery(this).val('');
		}
	});
	
	//Buttons Click Event
	jQuery('#cont_btn-1').click(function()
	{  
		var btn = jQuery(this).attr("id").split("-");
		ajaxForm(btn[1], p, '#cont_btn-1', '#cont-form-', '#contact_form','#form_ldr_box', '', 'yes');
	});
}

//Page Content Sliding Event
function slideEvent(btn,div,att,act)
{
	//Slding Event
	jQuery(btn).click(function()
	{  
		if(jQuery(''+div+jQuery(this).attr(att)+'').css('display') == 'block')
		{
			jQuery(''+div+jQuery(this).attr(att)+'').slideUp('fast');

			if(act != ""){  jQuery(this).removeClass(act);  }
		}
		else
		{
			jQuery(''+div+jQuery(this).attr(att)+'').slideDown('fast');

			if(act != ""){  jQuery(this).addClass(act);  }
		}
	});
}

//Page Content Sliding Event For Onlick Event
function slideAjaxEvent(div,speed){   jQuery(''+div+'').slideToggle('fast');   }

//News Slider Event
function newsSlide(id_1, id_2, pos, speed)
{
	eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$2={Q:{R:"S 2 T w U",V:0.4,W:"X Y (Z://10.11)",12:"13 14 15"},5:{g:[],x:16,s:{6:/([0-9,.\\-]+)6/}},h:{m:0,y:0},17:j(a,b,c,d,e){3($(a).F&&$(b).F&&c&&d>=1){$(a).k({18:\'19\'});$(b).k({1a:\'1b\',7:0,8:0});3(e){$(b).1c(j(){$2.n($(b),1d)},j(){$2.n($(b),G)})}$2.5.g.1e({z:$(a),f:$(b),H:c,o:d,n:G})}},n:j(a,b){3(a&&I b!==\'J\'){w(t i K $2.5.g){3($2.5.g[i].f.L("M")===a.L("M")){$2.5.g[i].n=b}}}},p:j(){3($2.h.m===0&&$2.5.x>0){$2.h.m=l.1f($2.A,$2.5.x)}3(!$2.h.y){$(l).1g($2.N);$(l).O($2.p);$(l).1h($2.p);$(l).A($2.p);$(1i).1j($2.p);3($.1k.1l){l.O()}$2.h.y=1}},N:j(){3($2.h.m){l.1m($2.h.m);$2.h.m=0}},B:{6:j(a){t b=\'\';3(a){3(a.C($2.5.s.6)){3(I a.C($2.5.s.6)[1]!==\'J\'){b=a.C($2.5.s.6)[1]}}}1n b}},A:j(){w(t i K $2.5.g){3($2.5.g.1o(i)){t a=$2.5.g[i],7=P(($2.B.6(a.f.k(\'7\'))||0)),8=P(($2.B.6(a.f.k(\'8\'))||0)),D=a.z.q(),E=a.z.r(),q=a.f.q(),r=a.f.r();3(!a.n){1p(a.H){u\'1q\':3(8<=-1*q){8=D}a.f.k(\'8\',8-a.o+\'6\');v;u\'1r\':3(7>=E){7=-1*r}a.f.k(\'7\',7+a.o+\'6\');v;u\'7\':3(7<=-1*r){7=E}a.f.k(\'7\',7-a.o+\'6\');v;u\'1s\':3(8>=D){8=-1*q}a.f.k(\'8\',8+a.o+\'6\');v}}}}}};',62,91,'||jScroller|if||config|px|left|top|||||||child|obj|cache||function|css|window|timer|pause|speed|start|height|width|regExp|var|case|break|for|refresh|init|parent|scroll|get|match|min_height|min_width|length|false|direction|typeof|undefined|in|attr|id|stop|focus|Number|info|Name|ByRei|Plugin|jQuery|Version|Author|Markus|Bordihn|http|markusbordihn|de|Description|Next|Generation|Autoscroller|120|add|overflow|hidden|position|absolute|hover|true|push|setInterval|blur|resize|document|mousemove|browser|msie|clearInterval|return|hasOwnProperty|switch|up|right|down'.split('|'),0,{}))

	//Slider Speed Controller
	$jScroller.config.refresh=speed;
	
	// Add Scroller Object
	$jScroller.add(id_1, id_2, pos, 1, "pause", 200);
	
	// Start Autoscroller
	$jScroller.start();
}

//Testimonial | Event Binding
function loadTestimonial(p,type)
{
	//Fade Out Testimonial Div
	jQuery('#testimonial').fadeOut('fast');

	//Sending Type
	var data='type='+type;

	//Sending Ajax Request For Testimonial
	jQuery.post(p+"testimonial.php",data,function(response)
	{
		jQuery('#testimonial').html(response);
		jQuery('#testimonial').fadeIn('fast');
	});
	
	//Set Time Out for Call Back
	setTimeout(function(){ loadTestimonial(p,type) }, 10000);
}


//PNG Transparent Maker For IE-6
function pngLoader(path)
{
	var clear = path+'clear.gif';
	document.write('<script type="text/javascript" id="ct" defer="defer" src="javascript:void(0)"><\/script>');var ct=document.getElementById("ct");ct.onreadystatechange=function(){pngfix()};pngfix=function(){var els=document.getElementsByTagName('*'),ip=/\.png/i,al="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='",i=els.length,uels=new Array(),c=0;while(i-->0){if(els[i].className.match(/unitPng/)){uels[c]=els[i];c++;}}if(uels.length==0)pfx(els);else pfx(uels);function pfx(els){i=els.length;while(i-->0){var el=els[i],es=el.style,elc=el.currentStyle,elb=elc.backgroundImage;if(el.src&&el.src.match(ip)&&!es.filter){es.height=el.height;es.width=el.width;es.filter=al+el.src+"',sizingMethod='crop')";el.src=clear;}else{if(elb.match(ip)){var path=elb.split('"'),rep=(elc.backgroundRepeat=='no-repeat')?'crop':'scale',elkids=el.getElementsByTagName('*'),j=elkids.length;es.filter=al+path[1]+"',sizingMethod='"+rep+"')";es.height=el.clientHeight+'px';es.backgroundImage='none';if(j!=0){if(elc.position!="absolute")es.position='static';while(j-->0)if(!elkids[j].style.position)elkids[j].style.position="relative";}}}}};};
}

//Registration Page Events
function registrationEvents(p, load_cap_1, load_cap_2, deact_form)
{
	//Tabs Click Event
	jQuery('#reg_tab-1, #reg_tab-2, #reg_tab-3').click(function()
	{  
		var tab = jQuery(this).attr("id").split("-");
		jQuery('.reg_tab_act1').removeClass('reg_tab_act1');
		jQuery('.reg_tab_act2').removeClass('reg_tab_act2');
		
		//Highlighting Tab
		if(tab[1] == 1){    jQuery(this).addClass('reg_tab_act1');    }else{    jQuery(this).addClass('reg_tab_act2');    }
		
		//Highlighting Content
		jQuery('#reg_frm-1, #reg_frm-2, #reg_frm-3').css('display','none');
		jQuery('#reg_frm-'+tab[1]+'').fadeIn('fast');
		
		//Hidding Error List Box
		jQuery('#error_box').slideUp('fast'); 
	});
	
	//Form On Click Event
	var form_field = '#reg_email1, #reg_email2, #reg_pass1, #reg_pass2, #reg_txt1, #reg_txt2, #reg_sec, #lgn_email, #lgn_pass, #pass_email, #pass_sec';
	jQuery(form_field).focus(function()
	{  
		if(jQuery(this).attr('class') != 'reg_act_field')
		{
			jQuery(this).removeClass();    jQuery(this).addClass('reg_act_field');    jQuery(this).val('');
		}
	});

	//Creating Capcha Image
	if(load_cap_1 == 1){   genCapcha(p, '#reg_sec_btn', '#reg_sec_pic', 'reg_sec', '334', '65','8');   }
	if(load_cap_2 == 1){   genCapcha(p, '#pass_sec_btn', '#pass_sec_pic', 'pass_sec', '334', '65','8');   }
	
	//Buttons Click Event
	jQuery('#reg_btn-1, #reg_btn-2, #reg_btn-3').click(function()
	{  
		var btn = jQuery(this).attr("id").split("-");
		ajaxForm(btn[1], p, '#reg_btn-1, #reg_btn-2, #reg_btn-3', '#reg_data-', '#reg_data_box','#form_ldr_box', '', deact_form);
	});
}

//Ajax Form Submission Event
function ajaxForm(n, p, btn, form, box, ldr, div, disable)
{
	//Deactivating Form Buttons
	jQuery(btn).unbind();
	
	//Unbinding Light Box Event 
	lightBoxEventUnbind();
	
	//Deactivating Form Objects
	var h = parseInt(jQuery(box).css('height'))+6;
	jQuery(ldr).css('height',h);
	jQuery(ldr).fadeIn(120);
	
	//Saving Form Data
	var data = jQuery(''+form+n+'').serialize();
	
	//Sending Ajax Requests
	jQuery.post(p+"forms.php",data,function(response)
	{
		//alert(response);
		
		
		var chk_res = response.search('err-list'), chk_res2 = response.search('span'), chk_res3 = response.search('err-box1');
		//alert(response);
		
		if((chk_res != -1) || (chk_res2 != -1))
		{
			//Placing Error Data
			jQuery('#error_box').html(response);
			
			//Hidding Deactivator Box
			jQuery(ldr).fadeOut(100, function()
			{
				jQuery('#error_box').slideDown('fast', function()
				{    
					jQuery('html,body').animate({scrollTop: jQuery(box).offset().top},300);    
					
					//Light Box Event Binding
					if(div != ""){  lightBoxEventBind(div);  }
					
					//Check Form Desable or Not
					if((disable == "yes") && (chk_res2 != -1))
					{
						h = parseInt(h)-parseInt(jQuery('#error_box').css('height'))+7;
						jQuery('#form_deact_box').css('height',h);
						jQuery('#form_deact_box').fadeIn(180);
					}
					else
					{
						//Buttons Click Event
						jQuery(btn).click(function()
						{  
							var btn = jQuery(this).attr("id").split("-");
							ajaxForm(btn[1], p, btn, form, box, ldr, div, disable);
						});
					}
				});
			});
		}
		else
		{
			window.location=''+response+'';
			//alert(response);
		}
	});
}

//Generat Capcha Image Function
function genCapcha(p, unbind_id, load_id, session, w, h, n)
{
	jQuery(unbind_id).unbind();
	jQuery(load_id).html();
	var data = 'session_n='+session+'&w='+w+'&h='+h+'&num='+n;
	jQuery.post(p+'capcha_pic.php', data, function(response)
	{
		jQuery(load_id).html(response);
		jQuery(unbind_id).click(function(){    genCapcha(p, unbind_id, load_id, session, w, h, n);    });
	})
}

//Token Confirmation Onload Events
function tokenConfirm(p, t1)
{
	//Toll Tip | Mouse Hover Event	
	jQuery("#tkn-conf-que").hover(
		function (){  jQuery("#prc_tip").css('display', 'block');  }, 
		function (){  jQuery("#prc_tip").css('display', 'none');   }
	);

	//YES | Click Event	
	jQuery('#tkn-conf-lnk_1').click(function(){   tokenYES();   });

	//NO | Click Event	
	jQuery('#tkn-conf-lnk_2').click(function(){   tokenNO();   });

	//Proceed Button | Click Event	
	jQuery("#tkn-conf-btn").click(function(){   tokenCheck(p, t1);  });
}

//Token YES | Function
function tokenYES()
{
		jQuery('#tkn-conf-lnk_2').removeClass('tkn_cont1-act');	
		jQuery('#tkn-conf-box_2').slideUp('fast');	
		jQuery(this).addClass('tkn_cont1-act');	
		jQuery('#tkn-conf-box_1').slideDown('fast');
}

//Token NO | Function
function tokenNO()
{
		jQuery('#tkn-conf-lnk_1').removeClass('tkn_cont1-act');	
		jQuery('#tkn-conf-box_1').slideUp('fast');	
		jQuery(this).addClass('tkn_cont1-act');	
		jQuery('#tkn-conf-box_2').slideDown('fast');
}

//Token ID Check | Function
function tokenCheck(p, t1)
{
	jQuery('#tkn-conf-note').css('display', 'none');
	if(jQuery('#tkn-conf-id').val() == "")
	{   
		jQuery('#tkn-conf-note').html(t1).css('display', 'block');   
	}
	else
	{   
		//Deactivating All Items
		jQuery('#tkn-conf-note').css('display', 'none');
		jQuery('#tkn-conf-id').attr('readonly', 'readonly');
		jQuery('#tkn-conf-btn, #tkn-conf-lnk_1, #tkn-conf-lnk_2').unbind();

		//Saving Data For Post
		var data = 'code='+jQuery('#tkn-conf-id').val();
		
		//Send Ajax Request for check Code
		jQuery.post(p+'token_check.php', data, function(response)
		{
			//Checking Response
			var chk_res = response.search('http:');
			if(chk_res != -1)
			{
				window.location=''+response+'';
			}
			else
			{
				//Notifying User Error Message
				jQuery('#tkn-conf-note').html(response).css('display', 'block');	
				
				//Activating All Items
				jQuery('#tkn-conf-id').removeAttr('readonly');
				jQuery('#tkn-conf-lnk_1').click(function(){   tokenYES();   });
				jQuery('#tkn-conf-lnk_2').click(function(){   tokenNO();   });
				jQuery("#tkn-conf-btn").click(function(){   tokenCheck(p, t1);  });
			}
		})
	}
}
//Service Viewed Function
function serViewedEvent(p)
{
	//Form On Focus Event
	jQuery('#sec_code_fld').focus(function()
	{  
		if(jQuery(this).hasClass('ser_v_deact'))
		{
			jQuery(this).removeClass('ser_v_deact');  jQuery(this).val('');
		}
	});

	//Creating Capcha Image
	genCapcha(p, '#sec_code_btn', '#sec_code_pic', 'ser_view_sec', '385', '83','8');
	
	//Buttons Click Event
	jQuery('#ser_v_frm_btn-1').click(function()
	{  
		var btn = jQuery(this).attr("id").split("-");
		ajaxForm(btn[1], p, '#ser_v_frm_btn-1', '#ser_v_frm_data', '#ser_v_frm_cont','#form_ldr_box');
	});

	//Loading Slide Event For FAQ's
	slideEvent('.ser_faq-que','#faq_ans-','title',''); 
}

//Light Box Loader
function lightBoxLoader()
{
	//Placing All Light Box Data Into Body
	jQuery('body').append('<div id="light-box"><a id="light-close" href="javascript:void(0);">Close</a><div class="light-c1">&nbsp;</div><br clear="all" /><div id="light-data"></div><br clear="all" /><div class="light-c2">&nbsp;</div></div><div id="light-bg">&nbsp;</div>');

	//Setting Light Box Background Heigh For IE
	if ((jQuery.browser.msie) & (parseInt(jQuery.browser.version) == 6))
	{
		jQuery('#light-bg').css('height',''+document.body.offsetHeight+'px');
	}
	//Setting Light Box Background Tranparancy Setting For IE
	jQuery('#light-bg').css({'filter' : 'alpha(opacity=70)'});
}

//Light Box Display Function
function lightBoxShow(div)
{
	//Light Box Event Binding
	lightBoxEventBind(div);
	
	//Loading Content Into Light Box Container
	jQuery('#light-data').html(jQuery(div).html());

	//Cleaning Temprory Container
	jQuery(div).html('');

	//Light Box Set Display Position Function
	lightBoxSetPosition();

	//Displaying Light
	jQuery('#light-bg, #light-box, #light-box_tour').fadeIn('fast');	
}

//Light Box Loader
function lightBoxHide(div)
{
	//Unbinding Light Box Event 
	lightBoxEventUnbind();
	
	//Hidding Light Box Background
	jQuery('#light-bg').fadeOut('fast');

	//Hidding Cleaning Light Box Data Container
	jQuery('#light-box, #light-box_tour').fadeOut('fast', function()
	{  
		//Hidding Error Box
		jQuery('#error_box').css('display', 'none');
	
		//Loading Content Into Temprary Box
		jQuery(div).html(jQuery('#light-data').html());

		//Cleaning Light Box Container
		jQuery('#light-data').html('');
	});
}

//Light Box Set Display Position Function
function lightBoxSetPosition()
{
	var div_id = '#light-box, #light-box_2, #light-box_comp, #light-box_tour';
	
	//Setting Calculating Current Windows Position
	var topPos = jQuery(document).scrollTop() + ((jQuery(window).height() - (jQuery(''+div_id+'').height()))* 0.5);
	var leftPos = jQuery(document).scrollLeft() + ((jQuery(window).width() - (jQuery(''+div_id+'').width()))* 0.5);
	
	//Comparing Calculated Position to Document Position
	topPos	= Math.max(jQuery(document).scrollTop()+20, topPos);
	leftPos	= Math.max(jQuery(document).scrollLeft()+20, leftPos);
	
	//Applying Position to Light Box Container
	jQuery(''+div_id+'').css('top',''+topPos+'px');
	jQuery(''+div_id+'').css('left',''+leftPos+'px');
}

//Light Box Event Binding
function lightBoxEventBind(div)
{
	//Lightbox Closing On Click Event
	jQuery('#light-close, #light-bg').click(function(){   lightBoxHide(div);  });

	//Lightbox Closing On Keyprss Event
	jQuery(document).unbind('keydown.fb').bind('keydown.fb', function(e){   if(e.keyCode == 27){ lightBoxHide(div); }   });
}

//Light Box Event Unbinding
function lightBoxEventUnbind()
{
	//Unbinding Click Event
	jQuery('#light-close, #light-bg').unbind();
	
	//Unbinding Keyboard Event
	jQuery(document).unbind('keydown.fb');
}

//Latest News Updates | News Loader Event
function newsLoader(p, num)
{
	//Defining Active News
	var act_nw = num;

	//UnBinding Click Event
	jQuery('.nw-link').unbind();

	//Loading Preloeader
	jQuery('#news_ajax_data').html('<div class="nw-ldr"><div class="prc-ldr-bg"><div class="prc-ldr-icn"></div></div></div>');
	
	//Saving Data For Post
	var data = 'num='+num;
	
	//Send Ajax Request for check Code
	jQuery.post(p+'news_data.php', data, function(response)
	{
		//Hidding Preloeader
		jQuery('.nw-ldr').fadeOut('fast', function()
		{
			//Loading News Data
			jQuery('#news_ajax_data').html(response);	
			
			//News Click Event
			jQuery('.nw-link').click(function()
			{   
				var curr = jQuery(this).attr('name');
				if(curr != act_nw)
				{
					newsLoader(p, curr);
					jQuery('.nw-act').removeClass('nw-act');
					jQuery(this).addClass('nw-act');
					act_nw = curr;
				}
			});	
		});
	})
}

//Default Variables for Generating Duplicate DIVs
var totDiv, befDiv, delDiv=new Array(2); delDiv[0]=new Array();  delDiv[1]=new Array();

//Div Generator Click Events
function duplicatDivClickEvent(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, dellArray, swapClass, remove_text, limit, change_name)
{
	//Remove Duplicate Div Event
	$('.'+removeBtn).click(function()
	{  
		//Deactivating All Events
		$('.'+removeBtn).unbind();  $('#'+addBtn+'').unbind(); 

		//Calling Duplicate DIV Deleting Function
		duplicatDivDelete(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, $(this).attr('title'), dellArray, swapClass, remove_text, limit, change_name);  
	});

	//Add Duplicate Event
	$('#'+addBtn+'').click(function()
	{  
		//Deactivating All Events
		$('.'+removeBtn).unbind();  $('#'+addBtn+'').unbind(); 

		//Calling Duplicate Div Generator Function
		duplicatDivGenerator(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, dellArray, swapClass, remove_text, limit, change_name);
	})
}

//Div Generator Onload Function
function duplicatDivOnload(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, dellArray, swapClass, remove_text, limit, change_name)
{
	//Div Generator Click Events
	duplicatDivClickEvent(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, dellArray, swapClass, remove_text, limit, change_name);
}

//Duplicate Div Delete Function
function duplicatDivDelete(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, divNum, dellArray, swapClass, remove_text, limit, change_name)
{
		totDiv = $('#'+totDivID+'').val();
		totDiv = parseInt(totDiv)-1;  
		$('#'+totDivID+'').val(totDiv);
		delDiv[dellArray].push(divNum);
		$('#'+dupDivID+'_'+divNum+'').remove();

		//Div Generator Click Events
		duplicatDivClickEvent(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, dellArray, swapClass, remove_text, limit, change_name);
}

//Duplicate Div Generator Function
function duplicatDivGenerator(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, dellArray, swapClass, remove_text, limit, change_name)
{
	//Assigning Values in Total Div Counter
	totDiv = $('#'+totDivID+'').val();  totDiv = parseInt(totDiv)+1;       
	
	if(totDiv <= limit)
	{
		$('#'+totDivID+'').val(totDiv);
	
		//Checking Deleted DIVs
		if (delDiv[dellArray].length > 0)
		{
			for(var i=0; i<=delDiv[dellArray].length;)
			{
				var chkNum = delDiv[dellArray][i];   chkNum = parseInt(chkNum)-1;
				var chkDiv = $('#'+dupDivID+'_'+chkNum+'').size();
				if(chkDiv == 1)
				{    
					totDiv=delDiv[dellArray][i];  
					delDiv[dellArray].splice(i, 1); 
					i=delDiv[dellArray].length;
				}
				i++;
			}
		}
	
		//Finding Prevous Div
		befDiv = parseInt(totDiv)-1;
	
		var DivClassName = dupDivClass;
	
		//Saving Html Data Into String
		var html_data =$('#'+dupDivID+'_1').html();
	
		//Condition For Swapping Class
		if((swapClass == 1) & ($('#'+dupDivID+'_'+befDiv+'').attr('class') == 'pro_set2')){    DivClassName = 'pro_set3';    }
	
		//Updating Name Value For Key
		if(change_name == 1)
		{
			var name_val = parseInt(totDiv)-1;
			var dataUpdater = html_data.split('0[]');
			dataUpdater = dataUpdater.join(name_val+'[]');
			html_data = dataUpdater;
			//alert(html_data);
		}
			
		//Placing Content Into Duplicate Div
		$('#'+dupDivID+'_'+befDiv+'').after('<div class="'+DivClassName+'" id="'+dupDivID+'_'+totDiv+'">'+html_data+'</div>');
	
		//Adding Remove Button
		$('#'+dupDivID+'_'+totDiv+'').append('<div><a href="javascript:void(0);" class="'+removeBtn+'" title="'+totDiv+'">'+remove_text+'</a></div>');
	
		//Assigning Unique Number In Fields
		$('#'+dupDivID+'_'+totDiv+' .dup_num').html(totDiv);
	}
		
	//Div Generator Click Events 
	duplicatDivClickEvent(totDivID, dupDivID, addBtn, removeBtn, dupDivClass, dellArray, swapClass, remove_text, limit, change_name); 
}

//Comparision Light Box Handler
function compareLightbox(div)
{
	//Unbinding Lightbox Event
	jQuery('#light-close, #light-bg').unbind();

	//Setting Light Box Background Heigh For IE
	if ((jQuery.browser.msie) & (parseInt(jQuery.browser.version) == 6))
	{
		jQuery('#light-bg').css('height',''+document.body.offsetHeight+'px');
	}

	//Setting Light Box Background Tranparancy Setting For IE
	jQuery('#light-bg').css({'filter' : 'alpha(opacity=70)'});

	//Placing Light Box Data
	jQuery('#light-data').html(jQuery(''+div+'').html());

	//Light Box Set Display Position Function
	lightBoxSetPosition();
	
	//Displaying Light
	jQuery('#light-bg, #light-box_comp').fadeIn('fast');	

	//Lightbox Closing On Click Event
	jQuery('#light-close, #light-bg').click(function(){   jQuery('#light-bg, #light-box_comp').fadeOut('fast', function(){   jQuery('#light-data').html('');  });  });

	//Lightbox Closing On Keyprss Event
	jQuery(document).unbind('keydown.fb').bind('keydown.fb', function(e){   if(e.keyCode == 27){ jQuery('#light-bg, #light-box_comp').fadeOut('fast', function(){   jQuery('#light-data').html('');  }); }   });
}

//Tour Light Box Handler
function cloudTourLightbox(swf, player_asset)
{
	//Tour Button Box Onclick Handler
	jQuery('#cloud_tour_btn').click(function()
	{ 
		//Loading SWF Embaded Code
		jQuery('#cloud_tour').html('<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="680" height="471"><param name="movie" value="'+player_asset+'player.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="skin='+player_asset+'skin.swf&file=http://www.youtube.com/watch?v=kFXOXOQNl0Y&autostart=true" /><embed type="application/x-shockwave-flash" id="player2" name="player2" src="'+player_asset+'player.swf" width="680" height="471" allowscriptaccess="always" allowfullscreen="true" autostart="true" flashvars="file=http://www.youtube.com/watch?v=kFXOXOQNl0Y&skin='+player_asset+'skin.swf&autostart=true"/></object>');
								//jQuery('#cloud_tour').html('<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="680" height="471"><param name="movie" value="'+player_asset+'player.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="skin='+player_asset+'skin.swf&file='+swf+'intro_mp4.mp4&autostart=true" /><embed type="application/x-shockwave-flash"	id="player2" name="player2" src="'+player_asset+'player.swf" width="680" height="471" allowscriptaccess="always" allowfullscreen="true" autostart="true" flashvars="file='+swf+'intro_mp4.mp4&skin='+player_asset+'skin.swf&autostart=true"/></object>');
		
		
								//jQuery('#cloud_tour').html('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="680" height="441" id="TourData"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+swf+'intro.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent"><embed src="'+swf+'intro.swf" quality="high" width="680" height="441" name="TourData" wmode="transparent" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
		
		//Displaying Light
		lightBoxShow('#cloud_tour');
		
		//Clearing Time Out
		clearTimeout(autoplay[2]);
		
		//Tour Button Box Onclick Handler
		jQuery('#light-close, #light-bg').click(function(){    jQuery('#light-data').html('').css('height','471px'); jQuery('#light-close, #light-bg').unbind();   });

		//Unbinding Keyboard Event
		jQuery(document).unbind('keydown.fb');
		
		//Lightbox Closing On Keyprss Event
		jQuery(document).unbind('keydown.fb').bind('keydown.fb', function(e){   if(e.keyCode == 27){    jQuery('#light-data').html('').css('height','471px'); lightBoxHide('#cloud_tour');  }   });
	});
	
	//Setting Light Box Background Heigh For IE
	if ((jQuery.browser.msie) & (parseInt(jQuery.browser.version) == 6))
	{
		jQuery('#light-bg').css('height',''+document.body.offsetHeight+'px');
	}

	//Setting Light Box Background Tranparancy Setting For IE
	jQuery('#light-bg').css({'filter' : 'alpha(opacity=70)'});
}

//Tour Light Box Handler
function clearFormHandler()
{
	if(jQuery('.clear_form_field').val() == ' '){    jQuery('.clear_form_field').val('');   }
	
	//Top Search | Data Display Events
	jQuery('.clear_form_field').focus(function()
	{
		if(jQuery(this).val() == ' ')
		{   
			jQuery(this).val('');   
		}
	});
	
	//Top Search | Data Display Events
	jQuery('.clear_form_field').blur(function()
	{
		if(jQuery(this).val() == ' ')
		{   
			jQuery(this).val('');
		}
	});
}

//Landing Page Javascript Validation
function javascriptValidation(form_id)
{
	//Temp data save here
	var i,j,k,l,temp_data_1,temp_data_2;
	var tot_field = jQuery('.form_field').length;
	var form_pregma = new Array();
	var form_data = new Array();
	var form_status = parseInt(jQuery('#form_status').val());
	
	if(form_status == 1)
	{
		jQuery(form_id).css('display','none');
		jQuery('#form_message').css('display','block');
	}
	
	//Form all Pregma Pettern Define Here
	form_pregma['email'] = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	//Saving Form Fields Data
	for(i=1; i<=tot_field; i++)
	{
		//Get Field Data
		temp_data_1 = jQuery('#form_field-'+i+'').val();
		temp_data_2 = jQuery('#form_field-'+i+'').attr('title').split("|-|");
		
		//Saving Field Data in Temp Array
		form_data[i] = new Array();
		form_data[i][1] = temp_data_1;
		form_data[i][2] = temp_data_2[0];
		form_data[i][3] = temp_data_2[1];
	}

	//Field | Focus Event
	jQuery('.form_field').focus(function()
	{
		if(jQuery(this).hasClass('form_inact'))
		{   
			jQuery(this).removeClass('form_inact');
			jQuery(this).val('');
		}
	});
	
	//Field | Blur Event
	jQuery('.form_field').blur(function()
	{
		if(jQuery(this).val() == '')
		{   
			temp_data_1 = jQuery(this).attr('id').split("-");
			jQuery(this).val(form_data[temp_data_1[1]][1]);
			jQuery(this).addClass('form_inact')
		}
	});

	//Form Submit | Handler
	jQuery('#form_button').click(function()
	{
		var error_msg='';
		
		//Checking all Fields
		for(i=1; i<=tot_field; i++)
		{
			//Get Field Data
			temp_data_1 = jQuery('#form_field-'+i+'').val();
			temp_data_2 = '';
			
			//Get Field Data
			if(form_data[i][2] != "not")
			{
				//Get Field Data
				if((temp_data_1 == "") || (temp_data_1 == form_data[i][1]))
				{
					temp_data_2 = form_data[i][3];
				}
				else if((form_data[i][2] == "email") && (!form_pregma[''+form_data[i][2]+''].test(temp_data_1)))
				{
					temp_data_2 = form_data[i][3];
				}
				
				//Add Error Msg
				error_msg += temp_data_2;
				
				//Add Line Break
				if((i<tot_field) && (temp_data_2 != "")){     error_msg += '\r\n';     }
			}
		}
		
		//Submit Form
		if(error_msg == "")
		{
			jQuery(form_id).submit();
		}
		else
		{
			alert(error_msg);			
		}
	});
}
