/*
 * 
 * Part of article How to detect screen size and apply a CSS style
 * http://www.ilovecolors.com.ar/detect-screen-size-css-style/
 *
 */

$(window).bind('load',function()
{

	$.ajax({
		type: "GET",
		url: "http://www.rattleyadags.co.nz",
		success: function(){
			$("#loading").hide().fadeOut(2000);
		}
	});
});
$.fn.windowchange = function(){
			//new line for whole image holder
    var innerW = $(window).width();
	var innerH = $(window).height();
    var numcol = 10.10;  
    var numrow = 6.02;  /*full screen fit calculation hacks*/
    var newimgWidth = innerW/numcol;
    var newimgHeight = innerH/numrow;
    
    var profileimgWidth = 5*newimgWidth;
    var profilecontentWidth = 3*newimgWidth;
	
	var fixedimgHeight = 135.38;
	var fixedimgWidth = 166.34;
	var ratio;
	if (newimgWidth > newimgHeight) { ratio = newimgHeight/fixedimgHeight;}
	else {ratio = newimgWidth/fixedimgWidth;}
	// New highlighter size when window resizing
	var newHLwidth = 50*ratio;
	var newHLheight = 50*ratio;
	
	var newfontsize = 24*ratio;
	var newCatLineHeight = 20*ratio;
	var newcrosssize = 120*ratio;
	
	var crossmarginLR = newimgWidth-newcrosssize;
	var crossmarginTB = newimgHeight-newcrosssize;
	
	var marginL = newimgWidth-newHLwidth;
	var marginT = newimgHeight-newHLheight;
	
	//logo text changes
	var newLogoSize = 60*newimgWidth/fixedimgWidth;
	var newLogoLineHeight = 42*ratio;
	var marginSize =12*ratio;
	
	//profile text changes
		var profiletxtSize = 18*ratio;
	var profileheadingSize = 24*ratio;
	var profiletextlineHeight = 20*ratio;
  var videolistimgWidth = 40*ratio;
  var listHeight = 30*ratio; 

	
  	 //alert (profileimgWidth +'width'+profilecontentWidth);
    $('#imgholder').css({'width':innerW,'height':innerH});
    if (newimgWidth>newimgHeight) {
		$('.singleimgbox li img').css({'width':newimgWidth,'height':'auto'});
	  $('.singleimgbox').css({'width':newimgWidth,'height':newimgHeight,'overflow':'hidden'});	
		$('.sidebox img').css({'width':newimgWidth,'height':newimgHeight});
		$('#categorybox').css({'width':newimgWidth,'height':newimgHeight});
		 //profile size resize right
		$('#profiler').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight}); 
    $('#profiler #profilecontent').css({'width':profilecontentWidth,'height':5*newimgHeight,'overflow':'hidden'});
    $('#profiler #profileimg').css({'width':profileimgWidth,'height':5*newimgHeight,'overflow':'hidden'});
  	$('#profiler #profileimg img').css({'width':profileimgWidth,'height':'auto'});
  	$('#profiler #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
  	$('#profiler #profilecontent .cross img').css({'width':newimgHeight-20,'height':newimgHeight-20,'margin-left':crossmarginLR,'margin-top':crossmarginTB});
  	$('#profiler #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
  	
    //profile left
    $('#profilel').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight}); 
    $('#profilel #profilecontent').css({'width':profilecontentWidth,'height':5*newimgHeight,'overflow':'hidden'});
    $('#profilel #profileimg').css({'width':profileimgWidth,'height':5*newimgHeight,'overflow':'hidden'});
  	$('#profilel #profileimg img').css({'width':profileimgWidth,'height':'auto'});
  	$('#profilel #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
  	$('#profilel #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgHeight-20,'margin-left':crossmarginLR,'margin-top':crossmarginTB});
  	$('#profilel #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
  	
		}else
		{
		$('.singleimgbox li img').css({'width':'auto','height':newimgHeight});
	    $('.singleimgbox').css({'width':newimgWidth,'height':newimgHeight,'overflow':'hidden'});	
		$('.sidebox img').css({'width':newimgWidth,'height':newimgHeight});
		$('#categorybox').css({'width':newimgWidth,'height':newimgHeight});
		 //profile size resize right
		$('#profiler').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight}); 
    $('#profiler #profilecontent').css({'width':profilecontentWidth,'height':5*newimgHeight,'overflow':'hidden'});
    $('#profiler #profileimg').css({'width':profileimgWidth,'height':5*newimgHeight,'overflow':'hidden'});
  	$('#profiler #profileimg img').css({'width':'auto','height':5*newimgHeight});
  	$('#profiler #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
  	$('#profiler #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgHeight-20,'margin-left':crossmarginLR,'margin-top':crossmarginTB});
  	$('#profiler #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
  	//profile left
    $('#profilel').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight}); 
    $('#profilel #profilecontent').css({'width':profilecontentWidth,'height':5*newimgHeight,'overflow':'hidden'});
    $('#profilel #profileimg').css({'width':profileimgWidth,'height':5*newimgHeight,'overflow':'hidden'});
  	$('#profilel #profileimg img').css({'width':'auto','height':5*newimgHeight});
  	$('#profilel #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
  	$('#profilel #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgHeight-20,'margin-left':crossmarginLR,'margin-top':crossmarginTB});
  	$('#profilel #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
    }
		
		//$('#logo img').css({'width':newimgWidth+50});
		$('#profilel').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight});
	  $('#profiler').css({'margin-top':newimgHeight,'margin-left':2*newimgWidth,'width':8*newimgWidth,'height':5*newimgHeight});
	  // highlighter
	 
   location.reload();
   $('.highlighter').css({'position':'absolute','margin-left':marginL, 'margin-top':marginT, 'background-size':newHLwidth, 'width':newHLwidth,'height':newHLheight});
   $('#categorybox ul li').css({'font-size': newfontsize});
   $('#categorybox').css({'line-height': newCatLineHeight+'px'});
   $('#logo').css({'font-size':newLogoSize+'px','line-height':newLogoLineHeight+'px','margin-left':marginSize+'px','margin-top':marginSize+'px'});
   
     //new profile text area
	 $('#profile_video .profile p').css({'font-size':12+'px','line-height':profiletextlineHeight+'px','margin':profiletxtSize+'px'});
   $('#profile_video .videolist ul li').css({'font-size':profiletxtSize+'px','list-style-image':'0'+ratio+'%'});
   $('.profile h2').css({'font-size':profileheadingSize+'px','margin':profiletxtSize+'px'});
   $('.videolist h2').css({'font-size':profileheadingSize+'px','margin':profiletxtSize+'px'});
   $('#profile_video .videolist ul li img').css({'width':videolistimgWidth});
   $('#profile_video .videolist ul li').css({'height':listHeight});
	  
}

 $.fn.getImgWidth = function() {
	var innerW = $(window).width();
    var numcol = 10.10;  
    var newimgWidth = innerW/numcol;
	return newimgWidth;
}
  $.fn.getImgHeight = function() {
	var innerH = $(window).height();
    var numrow = 6.02;  /*full screen fit calculation hacks*/
    var newimgHeight = innerH/numrow;
	return newimgHeight;
}
  $.fn.getHighlighterSize = function() {
	  var innerW = $(window).width();
	  var innerH = $(window).height();
	  var numcol = 10.10; 
	  var numrow = 6.02; 
	  var newimgWidth = innerW/numcol;
	  var newimgHeight = innerH/numrow;
	var fixedimgHeight = 135.38;
	var fixedimgWidth = 166.34;
	var ratio;
	if (newimgWidth > newimgHeight) 
	{ ratio = newimgHeight/fixedimgHeight;}
	else {ratio = newimgWidth/fixedimgWidth;}
	// New highlighter size when window resizing
	var newHLwidth = 50*ratio;
	var newHLheight = 50*ratio;
	return newHLwidth;
	}
  
  var kh = $('.singleimgbox li img').getImgHeight();
  var kw = $('.singleimgbox li img').getImgWidth();
  var hlsize = $('.highlighter').getHighlighterSize();
  var kh1;
  var kw1;
	if (kw > 166){kh1=kh-50;kw1=kw-50; hlsize=50;}
	else
	{kh1= kh-hlsize;kw1= kw-hlsize;}


$(document).ready(function() {

  var screenW = screen.width;
	var screenH = screen.height;
	var innerW = $(window).width();
	var innerH = $(window).height();
	var loadingimgMT = innerH-300;
	var loadingimgML = innerW-300;

	  var siteurl = "http://www.rattleyadags.co.nz";
	$('#loading').css({'width':screenW,'height':screenH, 'display':'block','background':'#000'});
	$('#loading img').css({'display':'block','background':'#000', 'margin-top':loadingimgMT/2,'margin-left':loadingimgML/2});
   //Logo append to its postion
  $('.sidebox[rel=042]').append('<div id="logo"><p>RATTLE</p><p>YA</p><p>DAGS</p></div>');
	  
    var innerW = $(window).width();
	  var innerH = $(window).height();
	  $(function(){  
		//new line for whole image holder
    var numcol = 10.10;  
    var numrow = 6.02;  /*full screen fit calculation hacks*/
    var newimgWidth = innerW/numcol;
    var newimgHeight = innerH/numrow;
	var fixedimgHeight = 135.38;
	var fixedimgWidth = 166.34;
	var ratio;
	if (newimgWidth > newimgHeight) 
	{ ratio = newimgHeight/fixedimgHeight;}
	else {ratio = newimgWidth/fixedimgWidth;}
	var newfontsize = 24*ratio;
	var newCatLineHeight = 20*ratio;

	//cross iamge changes
	var newcrosssize = 120*ratio;
	var crossmarginLR = newimgWidth-newcrosssize;
	var crossmarginTB = newimgHeight-newcrosssize;
	
	//logo text changes
	var newLogoSize = 60*ratio;
	var newLogoLineHeight = 42*ratio;
	var marginSize = 12*ratio;

  	//profile text changes
		var profiletxtSize = 18*ratio;
	var profileheadingSize = 24*ratio;
	var profiletextlineHeight = 20*ratio;
  var videolistimgWidth = 40*ratio;
  var listHeight = 30*ratio; 

    $('#imgholder').css({'width':innerW,'height':innerH});
    if (newimgWidth>newimgHeight) {
		$('.singleimgbox li img').css({'width':newimgWidth,'height':'auto'});
	  $('.singleimgbox').css({'width':newimgWidth,'height':newimgHeight,'overflow':'hidden'});	
		$('.sidebox img').css({'width':newimgWidth,'height':newimgHeight});
		$('#categorybox').css({'width':newimgWidth,'height':newimgHeight});
		//new added 20/01/2011
		$('#profiler #profilecontent .cross img').css({'width':newimgHeight-20,'height':newimgHeight-20,'margin-left':crossmarginLR,'margin-top':crossmarginTB});
		$('#profilel #profilecontent .cross img').css({'width':newimgHeight-20,'height':newimgHeight-20,'margin-left':crossmarginLR,'margin-top':crossmarginTB});
		 $('#logo').css({'font-size':newLogoSize+'px','line-height':newLogoLineHeight+'px','margin-left':marginSize,'margin-top':marginSize});
		}else
		{
		$('.singleimgbox li img').css({'width':'auto','height':newimgHeight});
	  $('.singleimgbox').css({'width':newimgWidth,'height':newimgHeight,'overflow':'hidden'});	
		$('.sidebox img').css({'width':newimgWidth,'height':newimgHeight});
		$('#categorybox').css({'width':newimgWidth,'height':newimgHeight});
		//
		$('#profiler #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgWidth-20,'margin-left':crossmarginLR,'margin-top':crossmarginTB});
		$('#profilel #profilecontent .cross img').css({'width':newimgHeight-20,'height':newimgHeight-20,'margin-left':crossmarginLR,'margin-top':crossmarginTB});
    }
		
	   $('#logo img').css('height',newimgHeight);
	   $('#profilel').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight});
	   $('#profiler').css({'margin-top':newimgHeight,'margin-left':2*newimgWidth,'width':8*newimgWidth,'height':5*newimgHeight});
	   $('#categorybox ul li').css({'font-size': newfontsize+'px'});
	   $('#categorybox').css({'line-height': newCatLineHeight+'px'});
	   ////logo text behavior
	   if (newimgHeight>3*newLogoSize){
	   $('#logo').css({'font-size':newLogoSize+'px','line-height':newLogoLineHeight+'px','margin-left':'auto','margin-top':newimgHeight-3*newLogoSize});}
	   else
	   {$('#logo').css({'font-size':newLogoSize+'px','line-height':newLogoLineHeight+'px','margin-left':'auto','margin-top':marginSize});}
	   
	        //new profile text area
	 $('#profile_video .profile p').css({'font-size':12+'px','line-height':profiletextlineHeight+'px','margin':profiletxtSize+'px'});
   $('#profile_video .videolist ul li').css({'font-size':profiletxtSize+'px','list-style-image':'0'+ratio+'%'});
   $('.profile h2').css({'font-size':profileheadingSize+'px','margin':profiletxtSize+'px'});
   $('.videolist h2').css({'font-size':profileheadingSize+'px','margin':profiletxtSize+'px'});
   $('#profile_video .videolist ul li img').css({'width':videolistimgWidth});
   $('#profile_video .videolist ul li').css({'height':listHeight});
	  


	});	
//'margin-left':crossmarginLR/2,'margin-top':crossmarginTB/2
/***************************************************/
 //Browser resize event
	
		/*new window resize event function*/
    $(window).bind('resize',function()
	{
		$(this).windowchange();
	});	 /*end of function*/

 //Black and white pics hover event 	 

 $('.singleimgbox li img').hover(function(){
 var idcode = $(this).attr('id').slice(2,5);
 $(this).fadeTo("slow", 0.9);
 $(this).attr({src : siteurl+'/wp-content/uploads/cl'+idcode+'.jpg'}).fadeTo("slow",1.0);  
 },
 function(){
  var idcode1 = $(this).attr('id').slice(2,5);
  $(this).attr({src : siteurl+'/wp-content/uploads/bw'+idcode1+'.jpg'}).fadeTo("slow",1.0);
 }
 );
 
   //logo click event 04/02/2011
	   $('#logo').bind('click',function(){
	   	   $('#profilel').show("slide", { direction: "left" }, 1500);
	       $('#profilel').append( '<div id="profilecontent"><div class="cross"><img src="'+siteurl+'/wp-content/themes/ryd2/images/cross.png"></div><div id="profile_video"><div class="profile"><h2></h2><p class="sitesum">In 2008 New Zealand On Air commissioned Two Heads to film a series of short inspirational videos with a cross-section of well-known kiwis. The best videos from the most viewed speakers are available here to view free of charge, anywhere in the world.</p></div><div class="videolist"><h2></h2><div class="summarylogos"></div></div></div></div><div id="profileimg"></div>'); 
	      
	       $('#bgmask').css({'display':'block'});
	        var numcol1 = 10.10;  
    var numrow1 = 6.02;  /*full screen fit calculation hacks*/
    var newimgWidth = innerW/numcol1;
    var newimgHeight = innerH/numrow1;
    
    var profileimgWidth = 5*newimgWidth;
    var profilecontentWidth = 3*newimgWidth;
	
	///////////////////////////////////////////
	var fixedimgHeight = 135.38;
	var fixedimgWidth = 166.34;
	var ratio;
	if (newimgWidth > newimgHeight) { ratio = newimgHeight/fixedimgHeight;}
	else {ratio = newimgWidth/fixedimgWidth;}
	// New highlighter size when window resizing
	var newHLwidth = 50*ratio;
	var newHLheight = 50*ratio;
	var marginL = newimgWidth-newHLwidth;
	var marginT = newimgHeight-newHLheight;
	//category changes
	var newfontsize = 24*ratio;
	var newCatLineHeight = 20*ratio;

	
    //cross iamge changes
	var newcrosssize = 120*ratio;
	var crossmarginLR = newimgWidth-newcrosssize;
	var crossmarginTB = newimgHeight-newcrosssize;
	
	//	logo text change
  var profiletxtSize = 18*ratio;
	
 if (newimgWidth>newimgHeight){     
    $('#profilel').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':3*newimgHeight}); 
    $('#profilel #profilecontent').css({'width':profilecontentWidth,'height':3*newimgHeight-1,'overflow':'hidden'});
    $('#profilel #profileimg').css({'width':profileimgWidth,'height':3*newimgHeight-1,'overflow':'hidden'});
	//$('#profilel #profileimg img').css({'width':profileimgWidth,'height':'auto'});
	$('#profilel #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
	$('#profilel #profilecontent .cross img').css({'width':'auto','height':newimgHeight});
	$('#profilel #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});

	$('#profilel #profilecontent .cross img').css({'width':newimgHeight-20,'height':newimgHeight-20,'margin-left':crossmarginLR/2,'margin-top':crossmarginTB});
	$(window).bind('resize',function(){$(this).windowchange();});
	} else
	{
    $('#profilel').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':3*newimgHeight}); 
    $('#profilel #profilecontent').css({'width':profilecontentWidth,'height':3*newimgHeight-2,'overflow':'hidden'});
    $('#profilel #profileimg').css({'width':profileimgWidth,'height':3*newimgHeight-2,'overflow':'hidden'});
	//$('#profilel #profileimg img').css({'width':'auto','height':5*newimgHeight});
	$('#profilel #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
	$('#profilel #profilecontent .cross img').css({'width':'auto','height':newimgHeight});
	$('#profilel #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
	//////////
	$('#profilel #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgWidth-20,'margin-left':crossmarginLR/4,'margin-top':crossmarginTB/2});
	$(window).bind('resize',function(){$(this).windowchange();});
    }
	  $('#profilel #profilecontent .profile p').css({'font-size':profiletxtSize});
     });
 //click image to retireve its details from posts via Json
 
  $('.singleimgbox li img').stop('img').live('click',(function(id){
  var id = $(this).attr('rel');var direction = $(this).attr('dir');
  $.getJSON('?json=get_post&post_id='+id+'&custom_fields=name,bigimage,colorimage,bwimage,video,direction&include=title,custom_fields,excerpt',function(profile){
	var title = profile.post.title;
	var excerpt = profile.post.excerpt;
	var name = profile.post.custom_fields.name;
	var bigimg = profile.post.custom_fields.bigimage;
	var colorimg = profile.post.custom_fields.colimage;
	var bwimg = profile.post.custom_fields.bwimage;
	var videolist = profile.post.custom_fields.video;
	var dir = profile.post.custom_fields.direction;
	if (videolist==''){var video=',,'}else{
	var videostr = videolist.toString();} 
	var strs = new Array();
	strs = videostr.split(",");
	var videocollection = {};
	var list='';
	
	/*****************/
    var numcol1 = 10.10;  
    var numrow1 = 6.02;  /*full screen fit calculation hacks*/
    var newimgWidth = innerW/numcol1;
    var newimgHeight = innerH/numrow1;
    
    var profileimgWidth = 5*newimgWidth;
    var profilecontentWidth = 3*newimgWidth;
	
	///////////////////////////////////////////
	var fixedimgHeight = 135.38;
	var fixedimgWidth = 166.34;
	var ratio;
	if (newimgWidth > newimgHeight) { ratio = newimgHeight/fixedimgHeight;}
	else {ratio = newimgWidth/fixedimgWidth;}
	// New highlighter size when window resizing
	var newHLwidth = 50*ratio;
	var newHLheight = 50*ratio;
	var marginL = newimgWidth-newHLwidth;
	var marginT = newimgHeight-newHLheight;
	//category changes
	var newfontsize = 24*ratio;
	var newCatLineHeight = 20*ratio;

	
    //cross iamge changes
	var newcrosssize = 120*ratio;
	var crossmarginLR = newimgWidth-newcrosssize;
	var crossmarginTB = newimgHeight-newcrosssize;
	
	  	//profile text changes
	var profiletxtSize = 18*ratio;
	var profileheadingSize = 24*ratio;
	var profiletextlineHeight = 20*ratio;
  var videolistimgWidth = 40*ratio;
  var listHeight = 30*ratio; 
	
	/////////////////////////////////////////////////
	
	/*****************/
	$(strs).each(function(index,val)
	{
	var key = (strs[index].split(':'));
	//var list1 = '<li><a href="http://www.youtube.com/watch?v='+key[1] +'&disablekb=1&showinfo=0" rel="prettyPhoto">'+key[0]+'</a></li>';
	var list1 = '<li id="'+index+'"><a href="http://www.youtube.com/watch?v='+key[1] +'&disablekb=1&showinfo=0" rel="prettyPhoto"><img src="'+siteurl+'/wp-content/themes/ryd2/images/videoplay40.png" id="'+index+'"/>'+key[0]+'</a></li>';
	val = list += list1;                
	
	return val;
	}); 	
    if (dir == 'right') { 
	$('#profiler').show("slide", { direction: "right" }, 1500);
	$('#profiler').append( '<div id="profilecontent"><div class="cross"><img src="'+siteurl+'/wp-content/themes/ryd2/images/cross.png"></div><div id="profile_video"><div class="profile"><h2>'+name+'</h2><p>'+excerpt+'</p></div><div class="videolist"><h2>'+strs.length+' Videos</h2><ul>'+list+'</ul></div> <!-- .videolist--></div></div><div id="profileimg"><img src="'+siteurl+'/wp-content/uploads/'+bigimg+'.jpg"/></div>'); 
	$('#bgmask').css({'display':'block'});

  /* profile slide from rigth side*/ 
  if (newimgWidth>newimgHeight){   
	$('#profiler').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight}); 
    $('#profiler #profilecontent').css({'width':profilecontentWidth,'height':5*newimgHeight,'overflow':'hidden'});
    $('#profiler #profileimg').css({'width':profileimgWidth,'height':5*newimgHeight,'overflow':'hidden'});
	$('#profiler #profileimg img').css({'width':profileimgWidth,'height':'auto'});
	$('#profiler #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
	$('#profiler #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgHeight});
	$('#profiler #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
	$(".videolist a[rel^='prettyPhoto']").prettyPhoto({modal: true,show_title:false,theme:'dark_square',callback:function(){$(window).bind('resize',function()
	{$(this).windowchange();});}});
	////////////////
	$('#profiler #profilecontent .cross img').css({'width':newimgHeight-20,'height':newimgHeight-20,'margin-left':crossmarginLR/2,'margin-top':crossmarginTB});
	$(window).bind('resize',function(){$(this).windowchange();});
	} else
	{
	$('#profiler').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight}); 
    $('#profiler #profilecontent').css({'width':profilecontentWidth,'height':5*newimgHeight,'overflow':'hidden'});
    $('#profiler #profileimg').css({'width':profileimgWidth,'height':5*newimgHeight,'overflow':'hidden'});
	$('#profiler #profileimg img').css({'width':'auto','height':5*newimgHeight});
	$('#profiler #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
	$('#profiler #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgHeight});
	$('#profiler #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
	$(".videolist a[rel^='prettyPhoto']").prettyPhoto({modal: true,show_title:false,theme:'dark_square',callback:function(){$(window).bind('resize',function()
	{$(this).windowchange();});}});
	/////////
	$('#profiler #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgWidth-20,'margin-left':crossmarginLR/4,'margin-top':crossmarginTB/2});
	$(window).bind('resize',function(){$(this).windowchange();});
  }
	}
	else if (dir == 'left') {
    $('#profilel').show("slide", { direction: "left" }, 1500);
	$('#profilel').append( '<div id="profileimg"><img src="'+siteurl+'/wp-content/uploads/'+bigimg+'.jpg"/></div><div id="profilecontent"><div class="cross"><img src="'+siteurl+'/wp-content/themes/ryd2/images/cross.png"></div><div id="profile_video"><div class="profile"><h2>'+name+'</h2><p>'+excerpt+'</p></div><div class="videolist"><h2>'+strs.length+' Videos</h2><ul>'+list+'</ul></div> <!-- .videolist--></div></div>'); 
	$('#bgmask').css({'display':'block'});
	 /*profile slide from left side*/ 
  if (newimgWidth>newimgHeight){     
    $('#profilel').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight}); 
    $('#profilel #profilecontent').css({'width':profilecontentWidth,'height':5*newimgHeight,'overflow':'hidden'});
    $('#profilel #profileimg').css({'width':profileimgWidth,'height':5*newimgHeight,'overflow':'hidden'});
	$('#profilel #profileimg img').css({'width':profileimgWidth,'height':'auto'});
	$('#profilel #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
	$('#profilel #profilecontent .cross img').css({'width':'auto','height':newimgHeight});
	$('#profilel #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
	$(".videolist a[rel^='prettyPhoto']").prettyPhoto({modal: true,show_title:false,theme:'dark_square',callback:function(){$(window).bind('resize',function()
	{$(this).windowchange();});}});
	$('#profilel #profilecontent .cross img').css({'width':newimgHeight-20,'height':newimgHeight-20,'margin-left':crossmarginLR/2,'margin-top':crossmarginTB});
	$(window).bind('resize',function(){$(this).windowchange();});
	} else
	{
    $('#profilel').css({'margin-top':newimgHeight,'width':8*newimgWidth,'height':5*newimgHeight}); 
    $('#profilel #profilecontent').css({'width':profilecontentWidth,'height':5*newimgHeight,'overflow':'hidden'});
    $('#profilel #profileimg').css({'width':profileimgWidth,'height':5*newimgHeight,'overflow':'hidden'});
	$('#profilel #profileimg img').css({'width':'auto','height':5*newimgHeight});
	$('#profilel #profilecontent .cross').css({'width':newimgWidth,'height':newimgHeight}); 
	$('#profilel #profilecontent .cross img').css({'width':'auto','height':newimgHeight});
	$('#profilel #profilecontent #profile_video').css({'width':3*newimgWidth,'height':4*newimgHeight});
	$(".videolist a[rel^='prettyPhoto']").prettyPhoto({modal: true,show_title:false,theme:'dark_square',callback:function(){$(window).bind('resize',function()
	{$(this).windowchange();});}});
	//////////
	$('#profilel #profilecontent .cross img').css({'width':newimgWidth-20,'height':newimgWidth-20,'margin-left':crossmarginLR/4,'margin-top':crossmarginTB/2});
	     //new profile text area
 	$(window).bind('resize',function(){$(this).windowchange();});
    }
    } /*end of */
  
  ////////////profile text resize on window resize
	 $('#profile_video .profile p').css({'font-size':12+'px','line-height':profiletextlineHeight+'px','margin':profiletxtSize+'px'});
   $('#profile_video .videolist ul li').css({'font-size':profiletxtSize+'px','list-style-image':'0'+ratio+'%'});
   $('.profile h2').css({'font-size':profileheadingSize+'px','margin':profiletxtSize+'px'});
   $('.videolist h2').css({'font-size':profileheadingSize+'px','margin':profiletxtSize+'px'});
   $('#profile_video .videolist ul li img').css({'width':videolistimgWidth});
   $('#profile_video .videolist ul li').css({'height':listHeight});
	  
   
   //////////
    $('#profile_video .videolist ul li').hover(function(){
    var id = $(this).attr('id');
    $('#profile_video .videolist ul li img[id='+id+']').attr({src : siteurl+'/wp-content/themes/ryd2/images/videoplay_hover40.png'})
    },
    function(){
    var id = $(this).attr('id');
         $('#profile_video .videolist ul li img[id='+id+']').attr({src : siteurl+'/wp-content/themes/ryd2/images/videoplay.png'})
    });  
   
});
}));
 
 
 $('#profilel #profilecontent .cross img').live('click',function(){
  $('#bgmask').css('display','none');
  $('#profilel').hide("slide", { direction: "left" }, 1500);
  $('#profilel').html('');
     $(window).bind('resize',function()
	{$(this).windowchange();
	});
 });
 //
  $('#profiler #profilecontent .cross img').live('click',function(){
  $('#bgmask').css('display','none');
  $('#profiler').hide("slide", { direction: "right" }, 1500);
  $('#profiler').html('');
     $(window).bind('resize',function()
	{$(this).windowchange();
	});
  });
 //

  var highlighterbox = '<div class=\"highlighter\"></div>';
  
  var businessgroup = $('.singleimgbox[rel=business]');
  var musicgroup = $('.singleimgbox[rel=music]');
  var sportgroup = $('.singleimgbox[rel=sport]');
  var mediagroup = $('.singleimgbox[rel=media]');
  var othergroup = $('.singleimgbox[rel=other]');
 

// Business Group
  $('li.catbusiness').toggle(function(){
									  //alert('hlsize'+hlsize+','+'margin-left'+kw1+',margin-top'+kh1+'imageHeight'+kh+',imageWidth:'+kw);
   $('#categorybox ul li').removeClass('highlighterClicked');								  
   $('.highlighter').css('display','none');
   $(businessgroup).append(highlighterbox).fadeIn(2500);
   $('.highlighter').css({'position':'absolute', 'margin-left':kw1, 'margin-top':kh1,'background-size':hlsize, 'width':hlsize,'height':hlsize});
   $(this).addClass('highlighterClicked');
   },function(){
   $('.highlighter').css('display','none');
   $(this).removeClass('highlighterClicked');
  });
// Music Group  
   $('li.catmusic').toggle(function(){
   $('#categorybox ul li').removeClass('highlighterClicked');	
   $('.highlighter').css('display','none');
   $(this).addClass('highlighterClicked');
   $(musicgroup).append(highlighterbox).fadeIn(2500);
   $('.highlighter').css({'position':'absolute', 'margin-left':kw1, 'margin-top':kh1,'background-size':hlsize, 'width':hlsize,'height':hlsize});
   },function(){
   $('.highlighter').css('display','none');
   $(this).removeClass('highlighterClicked');
  });
 // Music Group  
   $('li.catsport').toggle(function(){
   $('#categorybox ul li').removeClass('highlighterClicked');	
   $('.highlighter').css('display','none');
   $(this).addClass('highlighterClicked');
   $(sportgroup).append(highlighterbox).fadeIn(2500);
   $('.highlighter').css({'position':'absolute', 'margin-left':kw1, 'margin-top':kh1,'background-size':hlsize, 'width':hlsize,'height':hlsize});
   },function(){
   $('.highlighter').css('display','none');
   $(this).removeClass('highlighterClicked');
  });
//
// Media Group  
   $('li.catmedia').toggle(function(){
   $('#categorybox ul li').removeClass('highlighterClicked');	
   $('.highlighter').css('display','none');
   $(this).addClass('highlighterClicked');
   $(mediagroup).append(highlighterbox).fadeIn(2500);
   $('.highlighter').css({'position':'absolute','margin-left':kw1, 'margin-top':kh1,'background-size':hlsize, 'width':hlsize,'height':hlsize});
   },function(){
   $('.highlighter').css('display','none');
   $(this).removeClass('highlighterClicked');
  });
// Other Group  
   $('li.catother').toggle(function(){
   $('#categorybox ul li').removeClass('highlighterClicked');	
   $('.highlighter').css('display','none');
   $(this).addClass('highlighterClicked');
   $(othergroup).append(highlighterbox).fadeIn(2500);
   $('.highlighter').css({'position':'absolute','margin-left':kw1, 'margin-top':kh1,'background-size':hlsize, 'width':hlsize,'height':hlsize});
   },function(){
   $('.highlighter').css('display','none');
   $(this).removeClass('highlighterClicked');
   $('li.catother').stop('toggle');
  });
    

});


